240 #ifndef NK_NUKLEAR_H_
241 #define NK_NUKLEAR_H_
253 #define NK_UNDEFINED (-1.0f)
254 #define NK_UTF_INVALID 0xFFFD
255 #define NK_UTF_SIZE 4
257 #define NK_INPUT_MAX 16
259 #ifndef NK_MAX_NUMBER_BUFFER
260 #define NK_MAX_NUMBER_BUFFER 64
262 #ifndef NK_SCROLLBAR_HIDING_TIMEOUT
263 #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
274 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
275 #define NK_API static inline
276 #elif defined(__cplusplus)
277 #define NK_API static inline
279 #define NK_API static
282 #define NK_API extern
286 #define NK_INTERN static
287 #define NK_STORAGE static
288 #define NK_GLOBAL static
290 #define NK_FLAG(x) (1 << (x))
291 #define NK_STRINGIFY(x) #x
292 #define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
293 #define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
294 #define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
295 #define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
298 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
300 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
303 #ifndef NK_STATIC_ASSERT
304 #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
309 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
311 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
315 #define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
316 #define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
317 #define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
325 #ifdef NK_INCLUDE_FIXED_TYPES
327 #define NK_INT8 int8_t
328 #define NK_UINT8 uint8_t
329 #define NK_INT16 int16_t
330 #define NK_UINT16 uint16_t
331 #define NK_INT32 int32_t
332 #define NK_UINT32 uint32_t
333 #define NK_SIZE_TYPE uintptr_t
334 #define NK_POINTER_TYPE uintptr_t
340 #define NK_UINT8 unsigned char
343 #define NK_INT16 signed short
346 #define NK_UINT16 unsigned short
349 #if defined(_MSC_VER)
350 #define NK_INT32 __int32
352 #define NK_INT32 signed int
356 #if defined(_MSC_VER)
357 #define NK_UINT32 unsigned __int32
359 #define NK_UINT32 unsigned int
363 #if defined(_WIN64) && defined(_MSC_VER)
364 #define NK_SIZE_TYPE unsigned __int64
365 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
366 #define NK_SIZE_TYPE unsigned __int32
367 #elif defined(__GNUC__) || defined(__clang__)
368 #if defined(__x86_64__) || defined(__ppc64__)
369 #define NK_SIZE_TYPE unsigned long
371 #define NK_SIZE_TYPE unsigned int
374 #define NK_SIZE_TYPE unsigned long
377 #ifndef NK_POINTER_TYPE
378 #if defined(_WIN64) && defined(_MSC_VER)
379 #define NK_POINTER_TYPE unsigned __int64
380 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
381 #define NK_POINTER_TYPE unsigned __int32
382 #elif defined(__GNUC__) || defined(__clang__)
383 #if defined(__x86_64__) || defined(__ppc64__)
384 #define NK_POINTER_TYPE unsigned long
386 #define NK_POINTER_TYPE unsigned int
389 #define NK_POINTER_TYPE unsigned long
429 struct nk_draw_command;
437 struct nk_draw_vertex_layout_element;
441 struct nk_style_slide;
540 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
600 #ifdef NK_INCLUDE_COMMAND_USERDATA
1011 #define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1012 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1047 NK_API const struct nk_draw_command* nk__draw_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_context*);
1053 #define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1815 #define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
1816 #define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
1818 #define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
1819 #define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
1883 #ifdef NK_INCLUDE_STANDARD_VARARGS
1890 NK_API void nk_value_uint(
struct nk_context*,
const char *prefix,
unsigned int);
1990 NK_API double nk_propertyd(
struct nk_context*,
const char *name,
double min,
double val,
double max,
double step,
float inc_per_pixel);
2312 NK_API const char*
nk_utf_at(
const char *buffer,
int length,
int index, nk_rune *unicode,
int *len);
2462 struct nk_user_font_glyph;
2465 struct nk_user_font_glyph *glyph,
2466 nk_rune codepoint, nk_rune next_codepoint);
2468 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
2469 struct nk_user_font_glyph {
2474 float width, height;
2488 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
2496 #ifdef NK_INCLUDE_FONT_BAKING
2497 enum nk_font_coord_type {
2502 struct nk_baked_font {
2505 float ascent, descent;
2507 nk_rune glyph_offset;
2509 nk_rune glyph_count;
2511 const nk_rune *ranges;
2515 struct nk_font_config {
2516 struct nk_font_config *next;
2525 unsigned char ttf_data_owned_by_atlas;
2527 unsigned char merge_mode;
2529 unsigned char pixel_snap;
2531 unsigned char oversample_v, oversample_h;
2533 unsigned char padding[3];
2537 enum nk_font_coord_type coord_type;
2541 const nk_rune *range;
2543 struct nk_baked_font *font;
2545 nk_rune fallback_glyph;
2549 struct nk_font_glyph {
2552 float x0, y0, x1, y1, w, h;
2553 float u0, v0, u1, v1;
2557 struct nk_font *next;
2559 struct nk_baked_font info;
2561 struct nk_font_glyph *glyphs;
2562 const struct nk_font_glyph *fallback;
2563 nk_rune fallback_codepoint;
2565 struct nk_font_config *
config;
2568 enum nk_font_atlas_format {
2569 NK_FONT_ATLAS_ALPHA8,
2570 NK_FONT_ATLAS_RGBA32
2573 struct nk_font_atlas {
2585 struct nk_font_glyph *glyphs;
2586 struct nk_font *default_font;
2587 struct nk_font *fonts;
2588 struct nk_font_config *
config;
2593 NK_API const nk_rune *nk_font_default_glyph_ranges(
void);
2594 NK_API const nk_rune *nk_font_chinese_glyph_ranges(
void);
2595 NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(
void);
2596 NK_API const nk_rune *nk_font_korean_glyph_ranges(
void);
2598 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2599 NK_API void nk_font_atlas_init_default(
struct nk_font_atlas*);
2603 NK_API void nk_font_atlas_begin(
struct nk_font_atlas*);
2604 NK_API struct nk_font_config nk_font_config(float pixel_height);
2605 NK_API struct nk_font *nk_font_atlas_add(
struct nk_font_atlas*,
const struct nk_font_config*);
2606 #ifdef NK_INCLUDE_DEFAULT_FONT
2607 NK_API struct nk_font* nk_font_atlas_add_default(
struct nk_font_atlas*,
float height,
const struct nk_font_config*);
2609 NK_API struct nk_font* nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory, nk_size size,
float height,
const struct nk_font_config *
config);
2610 #ifdef NK_INCLUDE_STANDARD_IO
2611 NK_API struct nk_font* nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
float height,
const struct nk_font_config*);
2613 NK_API struct nk_font *nk_font_atlas_add_compressed(
struct nk_font_atlas*,
void *memory, nk_size size,
float height,
const struct nk_font_config*);
2614 NK_API struct nk_font* nk_font_atlas_add_compressed_base85(
struct nk_font_atlas*,
const char *data,
float height,
const struct nk_font_config *
config);
2615 NK_API const void* nk_font_atlas_bake(
struct nk_font_atlas*,
int *width,
int *height,
enum nk_font_atlas_format);
2617 NK_API const struct nk_font_glyph* nk_font_find_glyph(
struct nk_font*, nk_rune unicode);
2618 NK_API void nk_font_atlas_cleanup(
struct nk_font_atlas *atlas);
2619 NK_API void nk_font_atlas_clear(
struct nk_font_atlas*);
2703 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2733 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2802 #ifndef NK_TEXTEDIT_UNDOSTATECOUNT
2803 #define NK_TEXTEDIT_UNDOSTATECOUNT 99
2806 #ifndef NK_TEXTEDIT_UNDOCHARCOUNT
2807 #define NK_TEXTEDIT_UNDOCHARCOUNT 999
2874 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2964 #ifdef NK_INCLUDE_COMMAND_USERDATA
3100 unsigned short w,
unsigned short h, nk_handle callback_data);
3136 NK_API void nk_stroke_curve(
struct nk_command_buffer*,
float,
float,
float,
float,
float,
float,
float,
float,
float line_thickness,
struct nk_color);
3215 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
3229 typedef nk_ushort nk_draw_index;
3230 enum nk_draw_list_stroke {
3237 enum nk_draw_vertex_layout_attribute {
3241 NK_VERTEX_ATTRIBUTE_COUNT
3244 enum nk_draw_vertex_layout_format {
3254 NK_FORMAT_COLOR_BEGIN,
3255 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
3256 NK_FORMAT_R16G15B16,
3257 NK_FORMAT_R32G32B32,
3261 NK_FORMAT_R16G15B16A16,
3262 NK_FORMAT_R32G32B32A32,
3263 NK_FORMAT_R32G32B32A32_FLOAT,
3264 NK_FORMAT_R32G32B32A32_DOUBLE,
3268 NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
3272 #define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
3273 struct nk_draw_vertex_layout_element {
3274 enum nk_draw_vertex_layout_attribute attribute;
3275 enum nk_draw_vertex_layout_format format;
3279 struct nk_draw_command {
3280 unsigned int elem_count;
3286 #ifdef NK_INCLUDE_COMMAND_USERDATA
3291 struct nk_draw_list {
3293 struct nk_vec2 circle_vtx[12];
3300 unsigned int element_count;
3301 unsigned int vertex_count;
3302 unsigned int cmd_count;
3305 unsigned int path_count;
3306 unsigned int path_offset;
3311 #ifdef NK_INCLUDE_COMMAND_USERDATA
3317 NK_API void nk_draw_list_init(
struct nk_draw_list*);
3319 NK_API void nk_draw_list_clear(
struct nk_draw_list*);
3322 #define nk_draw_list_foreach(cmd, can, b) for((cmd)=nk__draw_list_begin(can, b); (cmd)!=0; (cmd)=nk__draw_list_next(cmd, b, can))
3323 NK_API const struct nk_draw_command* nk__draw_list_begin(
const struct nk_draw_list*,
const struct nk_buffer*);
3324 NK_API const struct nk_draw_command* nk__draw_list_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_draw_list*);
3325 NK_API const struct nk_draw_command* nk__draw_list_end(
const struct nk_draw_list*,
const struct nk_buffer*);
3326 NK_API void nk_draw_list_clear(
struct nk_draw_list *list);
3329 NK_API void nk_draw_list_path_clear(
struct nk_draw_list*);
3330 NK_API void nk_draw_list_path_line_to(
struct nk_draw_list*,
struct nk_vec2 pos);
3331 NK_API void nk_draw_list_path_arc_to_fast(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
int a_min,
int a_max);
3332 NK_API void nk_draw_list_path_arc_to(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
float a_min,
float a_max,
unsigned int segments);
3333 NK_API void nk_draw_list_path_rect_to(
struct nk_draw_list*,
struct nk_vec2 a,
struct nk_vec2 b,
float rounding);
3334 NK_API void nk_draw_list_path_curve_to(
struct nk_draw_list*,
struct nk_vec2 p2,
struct nk_vec2 p3,
struct nk_vec2 p4,
unsigned int num_segments);
3335 NK_API void nk_draw_list_path_fill(
struct nk_draw_list*,
struct nk_color);
3336 NK_API void nk_draw_list_path_stroke(
struct nk_draw_list*,
struct nk_color,
enum nk_draw_list_stroke closed,
float thickness);
3340 NK_API void nk_draw_list_stroke_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding,
float thickness);
3342 NK_API void nk_draw_list_stroke_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color,
unsigned int segs,
float thickness);
3344 NK_API void nk_draw_list_stroke_poly_line(
struct nk_draw_list*,
const struct nk_vec2 *pnts,
const unsigned int cnt,
struct nk_color,
enum nk_draw_list_stroke,
float thickness,
enum nk_anti_aliasing);
3347 NK_API void nk_draw_list_fill_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding);
3350 NK_API void nk_draw_list_fill_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color col,
unsigned int segs);
3355 NK_API void nk_draw_list_add_text(
struct nk_draw_list*,
const struct nk_user_font*,
struct nk_rect,
const char *text,
int len,
float font_height,
struct nk_color);
3356 #ifdef NK_INCLUDE_COMMAND_USERDATA
3357 NK_API void nk_draw_list_push_userdata(
struct nk_draw_list*, nk_handle userdata);
3807 #ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
3808 #define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
3810 #ifndef NK_CHART_MAX_SLOT
3811 #define NK_CHART_MAX_SLOT 4
3908 #ifndef NK_WINDOW_MAX_NAME
3909 #define NK_WINDOW_MAX_NAME 64
4021 #ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
4022 #define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
4025 #ifndef NK_FONT_STACK_SIZE
4026 #define NK_FONT_STACK_SIZE 8
4029 #ifndef NK_STYLE_ITEM_STACK_SIZE
4030 #define NK_STYLE_ITEM_STACK_SIZE 16
4033 #ifndef NK_FLOAT_STACK_SIZE
4034 #define NK_FLOAT_STACK_SIZE 32
4037 #ifndef NK_VECTOR_STACK_SIZE
4038 #define NK_VECTOR_STACK_SIZE 16
4041 #ifndef NK_FLAGS_STACK_SIZE
4042 #define NK_FLAGS_STACK_SIZE 32
4045 #ifndef NK_COLOR_STACK_SIZE
4046 #define NK_COLOR_STACK_SIZE 32
4049 #define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
4050 struct nk_config_stack_##name##_element {\
4051 prefix##_##type *address;\
4052 prefix##_##type old_value;\
4054 #define NK_CONFIG_STACK(type,size)\
4055 struct nk_config_stack_##type {\
4057 struct nk_config_stack_##type##_element elements[size];\
4060 #define nk_float float
4090 #define NK_VALUE_PAGE_CAPACITY \
4091 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
4144 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4145 struct nk_draw_list draw_list;
4147 #ifdef NK_INCLUDE_COMMAND_USERDATA
4174 #define NK_PI 3.141592654f
4175 #define NK_UTF_INVALID 0xFFFD
4176 #define NK_MAX_FLOAT_PRECISION 2
4178 #define NK_UNUSED(x) ((void)(x))
4179 #define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
4180 #define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
4181 #define NK_ABS(a) (((a) < 0) ? -(a) : (a))
4182 #define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
4183 #define NK_INBOX(px, py, x, y, w, h)\
4184 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
4185 #define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
4186 (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0)))
4187 #define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
4188 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
4190 #define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
4191 #define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
4192 #define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
4193 #define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
4195 #define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
4196 #define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
4197 #define nk_zero_struct(s) nk_zero(&s, sizeof(s))
4203 #if defined(__PTRDIFF_TYPE__)
4204 # define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
4205 # define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
4206 #elif !defined(__GNUC__)
4207 # define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
4208 # define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
4209 #elif defined(NK_USE_FIXED_TYPES)
4210 # define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
4211 # define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
4213 # define NK_UINT_TO_PTR(x) ((void*)(x))
4214 # define NK_PTR_TO_UINT(x) ((nk_size)(x))
4217 #define NK_ALIGN_PTR(x, mask)\
4218 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
4219 #define NK_ALIGN_PTR_BACK(x, mask)\
4220 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
4222 #define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
4223 #define NK_CONTAINER_OF(ptr,type,member)\
4224 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
4231 template<
typename T>
struct nk_alignof;
4232 template<
typename T,
int size_diff>
struct nk_helper{
enum {
value = size_diff};};
4234 template<
typename T>
struct nk_alignof{
struct Big {T x;
char c;};
enum {
4236 #define NK_ALIGNOF(t) (nk_alignof<t>::value)
4237 #elif defined(_MSC_VER)
4238 #define NK_ALIGNOF(t) (__alignof(t))
4240 #define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
4251 #ifdef NK_IMPLEMENTATION
4253 #ifndef NK_POOL_DEFAULT_CAPACITY
4254 #define NK_POOL_DEFAULT_CAPACITY 16
4257 #ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE
4258 #define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024)
4261 #ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE
4262 #define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024)
4266 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4269 #ifdef NK_INCLUDE_STANDARD_IO
4272 #ifdef NK_INCLUDE_STANDARD_VARARGS
4277 #define NK_ASSERT(expr) assert(expr)
4281 #define NK_MEMSET nk_memset
4284 #define NK_MEMCPY nk_memcopy
4287 #define NK_SQRT nk_sqrt
4290 #define NK_SIN nk_sin
4293 #define NK_COS nk_cos
4296 #define NK_STRTOD nk_strtod
4299 #define NK_DTOA nk_dtoa
4302 #define NK_DEFAULT (-1)
4304 #ifndef NK_VSNPRINTF
4309 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\
4310 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
4311 (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\
4312 (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\
4313 defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
4314 #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a)
4316 #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a)
4320 #define NK_SCHAR_MIN (-127)
4321 #define NK_SCHAR_MAX 127
4322 #define NK_UCHAR_MIN 0
4323 #define NK_UCHAR_MAX 256
4324 #define NK_SSHORT_MIN (-32767)
4325 #define NK_SSHORT_MAX 32767
4326 #define NK_USHORT_MIN 0
4327 #define NK_USHORT_MAX 65535
4328 #define NK_SINT_MIN (-2147483647)
4329 #define NK_SINT_MAX 2147483647
4330 #define NK_UINT_MIN 0
4331 #define NK_UINT_MAX 4294967295u
4346 NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
4347 #define NK_FLOAT_PRECISION 0.00000000000001
4391 nk_inv_sqrt(
float number)
4394 const float threehalfs = 1.5f;
4395 union {nk_uint i;
float f;} conv = {0};
4398 conv.i = 0x5f375A84 - (conv.i >> 1);
4399 conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
4406 return x * nk_inv_sqrt(x);
4412 NK_STORAGE const float a0 = +1.91059300966915117e-31f;
4413 NK_STORAGE const float a1 = +1.00086760103908896f;
4414 NK_STORAGE const float a2 = -1.21276126894734565e-2f;
4415 NK_STORAGE const float a3 = -1.38078780785773762e-1f;
4416 NK_STORAGE const float a4 = -2.67353392911981221e-2f;
4417 NK_STORAGE const float a5 = +2.08026600266304389e-2f;
4418 NK_STORAGE const float a6 = -3.03996055049204407e-3f;
4419 NK_STORAGE const float a7 = +1.38235642404333740e-4f;
4420 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
4426 NK_STORAGE const float a0 = +1.00238601909309722f;
4427 NK_STORAGE const float a1 = -3.81919947353040024e-2f;
4428 NK_STORAGE const float a2 = -3.94382342128062756e-1f;
4429 NK_STORAGE const float a3 = -1.18134036025221444e-1f;
4430 NK_STORAGE const float a4 = +1.07123798512170878e-1f;
4431 NK_STORAGE const float a5 = -1.86637164165180873e-2f;
4432 NK_STORAGE const float a6 = +9.90140908664079833e-4f;
4433 NK_STORAGE const float a7 = -5.23022132118824778e-14f;
4434 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
4438 nk_round_up_pow2(nk_uint v)
4453 return nk_null_rect;
4479 return nk_rect(pos.x, pos.y, size.x, size.y);
4485 return nk_rect(r[0], r[1], r[2], r[3]);
4491 return nk_recti(r[0], r[1], r[2], r[3]);
4498 ret.
x = r.x; ret.y = r.y;
4506 ret.
x = r.w; ret.y = r.h;
4511 nk_shrink_rect(struct
nk_rect r, float amount)
4514 r.
w =
NK_MAX(r.w, 2 * amount);
4515 r.h =
NK_MAX(r.h, 2 * amount);
4516 res.x = r.x + amount;
4517 res.y = r.y + amount;
4518 res.w = r.w - 2 * amount;
4519 res.h = r.h - 2 * amount;
4527 r.h =
NK_MAX(r.h, 2 * pad.y);
4528 r.x += pad.x; r.y += pad.y;
4538 ret.
x =
x; ret.y =
y;
4570 NK_INTERN int nk_str_match_here(
const char *regexp,
const char *text);
4571 NK_INTERN int nk_str_match_star(
int c,
const char *regexp,
const char *text);
4572 NK_INTERN int nk_is_lower(
int c) {
return (c >=
'a' && c <=
'z') || (c >= 0xE0 && c <= 0xFF);}
4573 NK_INTERN int nk_is_upper(
int c){
return (c >=
'A' && c <=
'Z') || (c >= 0xC0 && c <= 0xDF);}
4574 NK_INTERN int nk_to_upper(
int c) {
return (c >=
'a' && c <=
'z') ? (c - (
'a' -
'A')) : c;}
4575 NK_INTERN int nk_to_lower(
int c) {
return (c >=
'A' && c <=
'Z') ? (c - (
'a' +
'A')) : c;}
4578 nk_memcopy(
void *dst0,
const void *src0, nk_size length)
4581 char *dst = (
char*)dst0;
4582 const char *src = (
const char*)src0;
4583 if (length == 0 || dst == src)
4587 #define nk_wsize sizeof(nk_word)
4588 #define nk_wmask (nk_wsize-1)
4589 #define NK_TLOOP(s) if (t) NK_TLOOP1(s)
4590 #define NK_TLOOP1(s) do { s; } while (--t)
4594 if ((t | (nk_ptr)dst) & nk_wmask) {
4595 if ((t ^ (nk_ptr)dst) & nk_wmask || length < nk_wsize)
4598 t = nk_wsize - (t & nk_wmask);
4600 NK_TLOOP1(*dst++ = *src++);
4602 t = length / nk_wsize;
4603 NK_TLOOP(*(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src;
4604 src += nk_wsize; dst += nk_wsize);
4605 t = length & nk_wmask;
4606 NK_TLOOP(*dst++ = *src++);
4611 if ((t | (nk_ptr)dst) & nk_wmask) {
4612 if ((t ^ (nk_ptr)dst) & nk_wmask || length <= nk_wsize)
4617 NK_TLOOP1(*--dst = *--src);
4619 t = length / nk_wsize;
4620 NK_TLOOP(src -= nk_wsize; dst -= nk_wsize;
4621 *(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src);
4622 t = length & nk_wmask;
4623 NK_TLOOP(*--dst = *--src);
4635 nk_memset(
void *ptr,
int c0, nk_size size)
4637 #define nk_word unsigned
4638 #define nk_wsize sizeof(nk_word)
4639 #define nk_wmask (nk_wsize - 1)
4640 nk_byte *dst = (nk_byte*)ptr;
4644 if ((c = (nk_byte)c0) != 0) {
4646 if (
sizeof(
unsigned int) > 2)
4651 dst = (nk_byte*)ptr;
4652 if (size < 3 * nk_wsize) {
4653 while (size--) *dst++ = (
nk_byte)c0;
4667 t = size / nk_wsize;
4669 *(nk_word*)((
void*)dst) = c;
4674 t = (size & nk_wmask);
4687 nk_zero(
void *ptr, nk_size size)
4690 NK_MEMSET(ptr, 0, size);
4698 while (str && *str++ !=
'\0') siz++;
4703 nk_strtoi(
const char *str,
const char **endptr)
4706 const char *p = str;
4713 while (*p ==
' ') p++;
4718 while (*p && *p >=
'0' && *p <=
'9') {
4719 value = value * 10 + (
int) (*p -
'0');
4728 nk_strtod(
const char *str,
const char **endptr)
4732 const char *p = str;
4740 while (*p ==
' ') p++;
4746 while (*p && *p !=
'.' && *p !=
'e') {
4747 value = value * 10.0 + (double) (*p -
'0');
4753 for(m = 0.1; *p && *p !=
'e'; p++ ) {
4754 value = value + (double) (*p -
'0') *
m;
4764 }
else if (*p ==
'+') {
4769 for (pow = 0; *p; p++)
4770 pow = pow * 10 + (
int) (*p -
'0');
4772 for (m = 1.0, i = 0; i < pow; i++)
4779 number = value * neg;
4786 nk_strtof(
const char *str,
const char **endptr)
4789 double double_value;
4790 double_value = NK_STRTOD(str, endptr);
4791 float_value = (float)double_value;
4804 if (c1 <= 'Z' && c1 >=
'A') {
4808 if (c2 <= 'Z' && c2 >=
'A') {
4812 return ((d >= 0) << 1) - 1;
4819 nk_stricmpn(
const char *s1,
const char *s2,
int n)
4830 if (c1 <= 'Z' && c1 >=
'A') {
4834 if (c2 <= 'Z' && c2 >=
'A') {
4838 return ((d >= 0) << 1) - 1;
4845 nk_str_match_here(
const char *regexp,
const char *text)
4847 if (regexp[0] ==
'\0')
4849 if (regexp[1] ==
'*')
4850 return nk_str_match_star(regexp[0], regexp+2, text);
4851 if (regexp[0] ==
'$' && regexp[1] ==
'\0')
4852 return *text ==
'\0';
4853 if (*text!=
'\0' && (regexp[0]==
'.' || regexp[0]==*text))
4854 return nk_str_match_here(regexp+1, text+1);
4859 nk_str_match_star(
int c,
const char *regexp,
const char *text)
4862 if (nk_str_match_here(regexp, text))
4864 }
while (*text !=
'\0' && (*text++ == c || c ==
'.'));
4877 if (regexp[0] ==
'^')
4878 return nk_str_match_here(regexp+1, text);
4880 if (nk_str_match_here(regexp, text))
4882 }
while (*text++ !=
'\0');
4888 const char *pattern,
int *out_score)
4896 #define NK_ADJACENCY_BONUS 5
4898 #define NK_SEPARATOR_BONUS 10
4900 #define NK_CAMEL_BONUS 10
4902 #define NK_LEADING_LETTER_PENALTY (-3)
4904 #define NK_MAX_LEADING_LETTER_PENALTY (-9)
4906 #define NK_UNMATCHED_LETTER_PENALTY (-1)
4910 char const * pattern_iter = pattern;
4918 char const * best_letter = 0;
4919 int best_letter_score = 0;
4924 if (!str || !str_len || !pattern)
return 0;
4925 while (str_iter < str_len)
4927 const char pattern_letter = *pattern_iter;
4928 const char str_letter = str[str_iter];
4930 int next_match = *pattern_iter !=
'\0' &&
4931 nk_to_lower(pattern_letter) == nk_to_lower(str_letter);
4932 int rematch = best_letter && nk_to_upper(*best_letter) == nk_to_upper(str_letter);
4934 int advanced = next_match && best_letter;
4935 int pattern_repeat = best_letter && *pattern_iter !=
'\0';
4936 pattern_repeat = pattern_repeat &&
4937 nk_to_lower(*best_letter) == nk_to_lower(pattern_letter);
4939 if (advanced || pattern_repeat) {
4940 score += best_letter_score;
4942 best_letter_score = 0;
4945 if (next_match || rematch)
4949 if (pattern_iter == pattern) {
4950 int count = (
int)(&str[str_iter] - str);
4951 int penalty = NK_LEADING_LETTER_PENALTY * count;
4952 if (penalty < NK_MAX_LEADING_LETTER_PENALTY)
4953 penalty = NK_MAX_LEADING_LETTER_PENALTY;
4960 new_score += NK_ADJACENCY_BONUS;
4964 new_score += NK_SEPARATOR_BONUS;
4967 if (prev_lower && nk_is_upper(str_letter))
4968 new_score += NK_CAMEL_BONUS;
4975 if (new_score >= best_letter_score) {
4977 if (best_letter != 0)
4978 score += NK_UNMATCHED_LETTER_PENALTY;
4980 best_letter = &str[str_iter];
4981 best_letter_score = new_score;
4985 score += NK_UNMATCHED_LETTER_PENALTY;
4990 prev_lower = nk_is_lower(str_letter) != 0;
4991 prev_separator = str_letter ==
'_' || str_letter ==
' ';
4998 score += best_letter_score;
5001 if (*pattern_iter !=
'\0')
5014 nk_string_float_limit(
char *
string,
int prec)
5024 if (dot == (prec+1)) {
5031 return (
int)(c -
string);
5035 nk_pow(
double x,
int n)
5040 n = (plus) ? n : -n;
5047 return plus ? r : 1.0 / r;
5051 nk_ifloord(
double x)
5053 x = (double)((
int)x - ((x < 0.0) ? 1 : 0));
5060 x = (float)((
int)x - ((x < 0.0f) ? 1 : 0));
5069 return (x > i) ? i+1: i;
5072 float r = x - (float)t;
5073 return (r > 0.0f) ? t+1: t;
5084 neg = (n < 0) ? 1 : 0;
5085 ret = (neg) ? (
int)-n : (
int)n;
5086 while ((ret / 10) > 0) {
5090 if (neg) exp = -exp;
5095 nk_strrev_ascii(
char *s)
5101 for (; i < end; ++i) {
5103 s[i] = s[len - 1 - i];
5109 nk_itoa(
char *s,
long n)
5122 s[i++] = (char)(
'0' + (n % 10));
5134 nk_dtoa(
char *s,
double n)
5137 int digit = 0, m = 0, m1 = 0;
5145 s[0] =
'0'; s[1] =
'\0';
5154 useExp = (m >= 14 || (neg && m >= 9) || m <= -9);
5155 if (neg) *(c++) =
'-';
5161 n = n / (double)nk_pow(10.0, m);
5170 while (n > NK_FLOAT_PRECISION || m >= 0) {
5171 double weight = nk_pow(10.0, m);
5173 double t = (double)n / weight;
5174 digit = nk_ifloord(t);
5175 n -= ((double)digit * weight);
5176 *(c++) = (
char)(
'0' + (char)digit);
5178 if (m == 0 && n > 0)
5195 *(c++) = (
char)(
'0' + (char)(m1 % 10));
5200 for (i = 0, j = m-1; i<j; i++, j--) {
5212 #ifdef NK_INCLUDE_STANDARD_VARARGS
5213 #ifndef NK_INCLUDE_STANDARD_IO
5215 nk_vsnprintf(
char *buf,
int buf_size,
const char *fmt, va_list args)
5220 NK_ARG_TYPE_DEFAULT,
5224 NK_ARG_FLAG_LEFT = 0x01,
5225 NK_ARG_FLAG_PLUS = 0x02,
5226 NK_ARG_FLAG_SPACE = 0x04,
5227 NK_ARG_FLAG_NUM = 0x10,
5228 NK_ARG_FLAG_ZERO = 0x20
5232 enum nk_arg_type arg_type = NK_ARG_TYPE_DEFAULT;
5233 int precision = NK_DEFAULT;
5234 int width = NK_DEFAULT;
5239 const char *iter = fmt;
5242 NK_ASSERT(buf_size);
5243 if (!buf || !buf_size || !fmt)
return 0;
5244 for (iter = fmt; *iter && len < buf_size; iter++) {
5246 while (*iter && (*iter !=
'%') && (len < buf_size))
5247 buf[len++] = *iter++;
5248 if (!(*iter) || len >= buf_size)
break;
5253 if (*iter ==
'-') flag |= NK_ARG_FLAG_LEFT;
5254 else if (*iter ==
'+') flag |= NK_ARG_FLAG_PLUS;
5255 else if (*iter ==
' ') flag |= NK_ARG_FLAG_SPACE;
5256 else if (*iter ==
'#') flag |= NK_ARG_FLAG_NUM;
5257 else if (*iter ==
'0') flag |= NK_ARG_FLAG_ZERO;
5264 if (*iter >=
'1' && *iter <=
'9') {
5270 }
else if (*iter ==
'*') {
5271 width = va_arg(args,
int);
5276 precision = NK_DEFAULT;
5280 precision = va_arg(args,
int);
5293 if (*(iter+1) ==
'h') {
5294 arg_type = NK_ARG_TYPE_CHAR;
5296 }
else arg_type = NK_ARG_TYPE_SHORT;
5298 }
else if (*iter ==
'l') {
5299 arg_type = NK_ARG_TYPE_LONG;
5301 }
else arg_type = NK_ARG_TYPE_DEFAULT;
5305 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5306 NK_ASSERT(precision == NK_DEFAULT);
5307 NK_ASSERT(width == NK_DEFAULT);
5310 }
else if (*iter ==
's') {
5312 const char *str = va_arg(args,
const char*);
5313 NK_ASSERT(str != buf &&
"buffer and argument are not allowed to overlap!");
5314 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5315 NK_ASSERT(precision == NK_DEFAULT);
5316 NK_ASSERT(width == NK_DEFAULT);
5317 if (str == buf)
return -1;
5318 while (str && *str && len < buf_size)
5319 buf[len++] = *str++;
5320 }
else if (*iter ==
'n') {
5322 signed int *n = va_arg(args,
int*);
5323 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5324 NK_ASSERT(precision == NK_DEFAULT);
5325 NK_ASSERT(width == NK_DEFAULT);
5327 }
else if (*iter ==
'c' || *iter ==
'i' || *iter ==
'd') {
5330 const char *num_iter;
5331 int num_len, num_print, padding;
5332 int cur_precision =
NK_MAX(precision, 1);
5333 int cur_width =
NK_MAX(width, 0);
5336 if (arg_type == NK_ARG_TYPE_CHAR)
5337 value = (
signed char)va_arg(args,
int);
5338 else if (arg_type == NK_ARG_TYPE_SHORT)
5339 value = (
signed short)va_arg(args,
int);
5340 else if (arg_type == NK_ARG_TYPE_LONG)
5341 value = va_arg(args,
signed long);
5342 else if (*iter ==
'c')
5343 value = (
unsigned char)va_arg(args,
int);
5344 else value = va_arg(args,
signed int);
5347 nk_itoa(number_buffer, value);
5349 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
5350 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
5351 padding =
NK_MAX(padding-1, 0);
5354 if (!(flag & NK_ARG_FLAG_LEFT)) {
5355 while (padding-- > 0 && (len < buf_size)) {
5356 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
5358 else buf[len++] =
' ';
5363 if ((flag & NK_ARG_FLAG_PLUS) && value >= 0 && len < buf_size)
5365 else if ((flag & NK_ARG_FLAG_SPACE) && value >= 0 && len < buf_size)
5369 num_print =
NK_MAX(cur_precision, num_len);
5370 while (precision && (num_print > num_len) && (len < buf_size)) {
5376 num_iter = number_buffer;
5377 while (precision && *num_iter && len < buf_size)
5378 buf[len++] = *num_iter++;
5381 if (flag & NK_ARG_FLAG_LEFT) {
5382 while ((padding-- > 0) && (len < buf_size))
5385 }
else if (*iter ==
'o' || *iter ==
'x' || *iter ==
'X' || *iter ==
'u') {
5387 unsigned long value = 0;
5388 int num_len = 0, num_print, padding = 0;
5389 int cur_precision =
NK_MAX(precision, 1);
5390 int cur_width =
NK_MAX(width, 0);
5391 unsigned int base = (*iter ==
'o') ? 8: (*iter ==
'u')? 10: 16;
5394 const char *upper_output_format =
"0123456789ABCDEF";
5395 const char *lower_output_format =
"0123456789abcdef";
5396 const char *output_format = (*iter ==
'x') ?
5397 lower_output_format: upper_output_format;
5400 if (arg_type == NK_ARG_TYPE_CHAR)
5401 value = (
unsigned char)va_arg(args,
int);
5402 else if (arg_type == NK_ARG_TYPE_SHORT)
5403 value = (
unsigned short)va_arg(args,
int);
5404 else if (arg_type == NK_ARG_TYPE_LONG)
5405 value = va_arg(args,
unsigned long);
5406 else value = va_arg(args,
unsigned int);
5410 int digit = output_format[value % base];
5412 number_buffer[num_len++] = (char)digit;
5414 }
while (value > 0);
5416 num_print =
NK_MAX(cur_precision, num_len);
5417 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
5418 if (flag & NK_ARG_FLAG_NUM)
5419 padding =
NK_MAX(padding-1, 0);
5422 if (!(flag & NK_ARG_FLAG_LEFT)) {
5423 while ((padding-- > 0) && (len < buf_size)) {
5424 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
5426 else buf[len++] =
' ';
5431 if (num_print && (flag & NK_ARG_FLAG_NUM)) {
5432 if ((*iter ==
'o') && (len < buf_size)) {
5434 }
else if ((*iter ==
'x') && ((len+1) < buf_size)) {
5437 }
else if ((*iter ==
'X') && ((len+1) < buf_size)) {
5442 while (precision && (num_print > num_len) && (len < buf_size)) {
5448 while (num_len > 0) {
5449 if (precision && (len < buf_size))
5450 buf[len++] = number_buffer[num_len-1];
5455 if (flag & NK_ARG_FLAG_LEFT) {
5456 while ((padding-- > 0) && (len < buf_size))
5459 }
else if (*iter ==
'f') {
5461 const char *num_iter;
5462 int cur_precision = (precision < 0) ? 6: precision;
5463 int prefix, cur_width =
NK_MAX(width, 0);
5464 double value = va_arg(args,
double);
5465 int num_len = 0, frac_len = 0, dot = 0;
5468 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5469 NK_DTOA(number_buffer, value);
5473 num_iter = number_buffer;
5474 while (*num_iter && *num_iter !=
'.')
5477 prefix = (*num_iter ==
'.')?(
int)(num_iter - number_buffer)+1:0;
5478 padding =
NK_MAX(cur_width - (prefix +
NK_MIN(cur_precision, num_len - prefix)) , 0);
5479 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
5480 padding =
NK_MAX(padding-1, 0);
5483 if (!(flag & NK_ARG_FLAG_LEFT)) {
5484 while (padding-- > 0 && (len < buf_size)) {
5485 if (flag & NK_ARG_FLAG_ZERO)
5487 else buf[len++] =
' ';
5492 num_iter = number_buffer;
5493 if ((flag & NK_ARG_FLAG_PLUS) && (value >= 0) && (len < buf_size))
5495 else if ((flag & NK_ARG_FLAG_SPACE) && (value >= 0) && (len < buf_size))
5498 if (dot) frac_len++;
5500 buf[len++] = *num_iter;
5501 if (*num_iter ==
'.') dot = 1;
5502 if (frac_len >= cur_precision)
break;
5507 while (frac_len < cur_precision) {
5508 if (!dot && len < buf_size) {
5518 if (flag & NK_ARG_FLAG_LEFT) {
5519 while ((padding-- > 0) && (len < buf_size))
5524 NK_ASSERT(0 &&
"specifier is not supported!");
5528 buf[(len >= buf_size)?(buf_size-1):len] = 0;
5529 result = (len >= buf_size)?-1:len;
5535 nk_strfmt(
char *buf,
int buf_size,
const char *fmt, va_list args)
5539 NK_ASSERT(buf_size);
5540 if (!buf || !buf_size || !fmt)
return 0;
5541 #ifdef NK_INCLUDE_STANDARD_IO
5542 result = NK_VSNPRINTF(buf, (nk_size)buf_size, fmt, args);
5543 result = (result >= buf_size) ? -1: result;
5544 buf[buf_size-1] = 0;
5546 result = nk_vsnprintf(buf, buf_size, fmt, args);
5556 #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
5557 union {
const nk_uint *i;
const nk_byte *b;} conv = {0};
5558 const nk_byte *data = (
const nk_byte*)key;
5559 const int nblocks = len/4;
5561 const nk_uint c1 = 0xcc9e2d51;
5562 const nk_uint c2 = 0x1b873593;
5563 const nk_byte *tail;
5564 const nk_uint *blocks;
5570 conv.b = (data + nblocks*4);
5571 blocks = (
const nk_uint*)conv.i;
5572 for (i = -nblocks; i; ++i) {
5575 k1 = NK_ROTL(k1,15);
5579 h1 = NK_ROTL(h1,13);
5580 h1 = h1*5+0xe6546b64;
5584 tail = (
const nk_byte*)(data + nblocks*4);
5587 case 3: k1 ^= (
nk_uint)(tail[2] << 16);
5588 case 2: k1 ^= (
nk_uint)(tail[1] << 8u);
5589 case 1: k1 ^= tail[0];
5591 k1 = NK_ROTL(k1,15);
5610 #ifdef NK_INCLUDE_STANDARD_IO
5612 nk_file_load(
const char* path, nk_size* siz,
struct nk_allocator *alloc)
5621 if (!path || !siz || !alloc)
5624 fd = fopen(path,
"rb");
5640 *siz = (
nk_size)fread(buf, *siz, 1, fd);
5654 nk_parse_hex(
const char *p,
int length)
5658 while (len < length) {
5660 if (p[len] >=
'a' && p[len] <=
'f')
5661 i += ((p[len] -
'a') + 10);
5662 else if (p[len] >=
'A' && p[len] <=
'F')
5663 i += ((p[len] -
'A') + 10);
5664 else i += (p[len] -
'0');
5685 const char *c = rgb;
5687 col.
r = (
nk_byte)nk_parse_hex(c, 2);
5688 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
5689 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
5698 const char *c = rgb;
5700 col.
r = (
nk_byte)nk_parse_hex(c, 2);
5701 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
5702 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
5703 col.a = (
nk_byte)nk_parse_hex(c+6, 2);
5710 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
5711 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
5712 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
5713 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
5714 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
5715 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
5716 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
5717 output[6] = (char)NK_TO_HEX((col.
a & 0xF0) >> 4);
5718 output[7] = (char)NK_TO_HEX((col.
a & 0x0F));
5726 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
5727 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
5728 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
5729 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
5730 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
5731 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
5732 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
5740 return nk_rgba(c[0], c[1], c[2], c[3]);
5746 return nk_rgba(c[0], c[1], c[2], c[3]);
5763 return nk_rgb(c[0], c[1], c[2]);
5769 return nk_rgb(c[0], c[1], c[2]);
5776 ret.
r = (in & 0xFF);
5777 ret.g = ((in >> 8) & 0xFF);
5778 ret.b = ((in >> 16) & 0xFF);
5779 ret.a = (
nk_byte)((in >> 24) & 0xFF);
5797 return nk_rgba_f(c[0], c[1], c[2], c[3]);
5818 nk_hsv(int h, int s, int v)
5826 return nk_hsv(c[0], c[1], c[2]);
5832 return nk_hsv(c[0], c[1], c[2]);
5836 nk_hsv_f(float h, float s, float v)
5848 nk_hsva(int h, int s, int v, int
a)
5850 float hf = ((float)
NK_CLAMP(0, h, 255)) / 255.0f;
5851 float sf = ((float)
NK_CLAMP(0, s, 255)) / 255.0f;
5852 float vf = ((float)
NK_CLAMP(0, v, 255)) / 255.0f;
5853 float af = ((float)
NK_CLAMP(0,
a, 255)) / 255.0f;
5860 return nk_hsva(c[0], c[1], c[2], c[3]);
5866 return nk_hsva(c[0], c[1], c[2], c[3]);
5870 nk_hsva_f(float h, float s, float v, float
a)
5877 out.
r = v; out.
g = v; out.
b = v;
5881 h = h / (60.0f/360.0f);
5885 q = v * (1.0f - (s * f));
5886 t = v * (1.0f - s * (1.0f - f));
5889 case 0:
default: out.r = v; out.g = t; out.b = p;
break;
5890 case 1: out.r = q; out.g = v; out.b = p;
break;
5891 case 2: out.r = p; out.g = v; out.b = t;
break;
5892 case 3: out.r = p; out.g = q; out.b = v;
break;
5893 case 4: out.r = t; out.g = p; out.b = v;
break;
5894 case 5: out.r = v; out.g = p; out.b = q;
break;
5902 return nk_hsva_f(c[0], c[1], c[2], c[3]);
5909 out |= ((nk_uint)in.
g << 8);
5919 *r = (float)in.
r * s;
5920 *g = (
float)in.
g * s;
5921 *b = (float)in.
b * s;
5922 *a = (
float)in.
a * s;
5935 *r = (double)in.
r * s;
5936 *g = (
double)in.
g * s;
5937 *b = (double)in.
b * s;
5938 *a = (
double)in.
a * s;
5963 float *out_v,
float *out_a,
struct nk_color in)
5971 const float t =
g; g =
b; b = t;
5975 const float t =
r; r =
g; g = t;
5978 chroma = r - ((g <
b) ? g: b);
5979 *out_h =
NK_ABS(K + (g - b)/(6.0f * chroma + 1e-20f));
5980 *out_s = chroma / (r + 1e-20f);
5982 *out_a = (float)in.
a / 255.0f;
5997 *out_h = (
nk_byte)(h * 255.0f);
5998 *out_s = (
nk_byte)(s * 255.0f);
5999 *out_v = (
nk_byte)(v * 255.0f);
6000 *out_a = (
nk_byte)(a * 255.0f);
6073 nk_handle handle = {0};
6091 nk_zero(&s,
sizeof(s));
6094 s.region[0] = (
unsigned short)r.x;
6095 s.region[1] = (
unsigned short)r.y;
6096 s.region[2] = (
unsigned short)r.w;
6097 s.region[3] = (
unsigned short)r.h;
6105 nk_zero(&s,
sizeof(s));
6108 s.region[0] = (
unsigned short)r.x;
6109 s.region[1] = (
unsigned short)r.y;
6110 s.region[2] = (
unsigned short)r.w;
6111 s.region[3] = (
unsigned short)r.h;
6120 nk_zero(&s,
sizeof(s));
6123 s.region[0] = (
unsigned short)r.x;
6124 s.region[1] = (
unsigned short)r.y;
6125 s.region[2] = (
unsigned short)r.w;
6126 s.region[3] = (
unsigned short)r.h;
6134 nk_zero(&s,
sizeof(s));
6148 nk_zero(&s,
sizeof(s));
6163 nk_zero(&s,
sizeof(s));
6177 return !(img->
w == 0 && img->
h == 0);
6181 nk_unify(
struct nk_rect *clip,
const struct nk_rect *a,
float x0,
float y0,
6196 float pad_x,
float pad_y,
enum nk_heading direction)
6198 float w_half, h_half;
6203 r.
w = r.
w - 2 * pad_x;
6204 r.
h = r.
h - 2 * pad_y;
6209 w_half = r.
w / 2.0f;
6210 h_half = r.
h / 2.0f;
6212 if (direction ==
NK_UP) {
6216 }
else if (direction ==
NK_RIGHT) {
6218 result[1] =
nk_vec2(r.
x + r.
w, r.
y + h_half);
6220 }
else if (direction ==
NK_DOWN) {
6223 result[2] =
nk_vec2(r.
x + w_half, r.
y + r.
h);
6232 nk_text_clamp(
const struct nk_user_font *font,
const char *text,
6233 int text_len,
float space,
int *glyphs,
float *text_width,
6234 nk_rune *sep_list,
int sep_count)
6238 float last_width = 0;
6239 nk_rune unicode = 0;
6247 float sep_width = 0;
6248 sep_count =
NK_MAX(sep_count,0);
6251 while (glyph_len && (width < space) && (len < text_len)) {
6254 for (i = 0; i < sep_count; ++i) {
6255 if (unicode != sep_list[i])
continue;
6256 sep_width = last_width = width;
6261 if (i == sep_count){
6262 last_width = sep_width = width;
6266 glyph_len =
nk_utf_decode(&text[len], &unicode, text_len - len);
6269 if (len >= text_len) {
6271 *text_width = last_width;
6275 *text_width = sep_width;
6276 return (!sep_len) ? len: sep_len;
6280 enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
6283 const char *begin,
int byte_len,
float row_height,
const char **remaining,
6284 struct nk_vec2 *out_offset,
int *glyphs,
int op)
6286 float line_height = row_height;
6288 float line_width = 0.0f;
6292 nk_rune unicode = 0;
6294 if (!begin || byte_len <= 0 || !font)
6298 if (!glyph_len)
return text_size;
6299 glyph_width = font->width(font->userdata, font->height, begin, glyph_len);
6302 while ((text_len < byte_len) && glyph_len) {
6303 if (unicode ==
'\n') {
6304 text_size.
x =
NK_MAX(text_size.
x, line_width);
6305 text_size.
y += line_height;
6308 if (op == NK_STOP_ON_NEW_LINE)
6312 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6316 if (unicode ==
'\r') {
6319 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6323 *glyphs = *glyphs + 1;
6324 text_len += glyph_len;
6325 line_width += (float)glyph_width;
6326 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6327 glyph_width = font->width(font->userdata, font->height, begin+text_len, glyph_len);
6331 if (text_size.
x < line_width)
6332 text_size.
x = line_width;
6334 *out_offset =
nk_vec2(line_width, text_size.
y + line_height);
6335 if (line_width > 0 || text_size.
y == 0.0f)
6336 text_size.
y += line_height;
6338 *remaining = begin+text_len;
6353 nk_utf_validate(nk_rune *u,
int i)
6357 if (!
NK_BETWEEN(*u, nk_utfmin[i], nk_utfmax[i]) ||
6360 for (i = 1; *u > nk_utfmax[i]; ++i);
6365 nk_utf_decode_byte(
char c,
int *i)
6369 for(*i = 0; *i < (
int)
NK_LEN(nk_utfmask); ++(*i)) {
6370 if (((nk_byte)c & nk_utfmask[*i]) == nk_utfbyte[*i])
6371 return (nk_byte)(c & ~nk_utfmask[*i]);
6379 int i, j, len, type=0;
6385 if (!c || !u)
return 0;
6386 if (!clen)
return 0;
6389 udecoded = nk_utf_decode_byte(c[0], &len);
6393 for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
6394 udecoded = (udecoded << 6) | nk_utf_decode_byte(c[i], &type);
6401 nk_utf_validate(u, len);
6406 nk_utf_encode_byte(nk_rune u,
int i)
6408 return (
char)((nk_utfbyte[i]) | ((nk_byte)u & ~nk_utfmask[i]));
6415 len = nk_utf_validate(&u, 0);
6419 for (i = len - 1; i != 0; --i) {
6420 c[i] = nk_utf_encode_byte(u, 0);
6423 c[0] = nk_utf_encode_byte(u, len);
6438 if (!str || !len)
return 0;
6443 while (glyph_len && src_len < len) {
6445 src_len = src_len + glyph_len;
6446 glyph_len =
nk_utf_decode(text + src_len, &unicode, text_len - src_len);
6452 nk_utf_at(
const char *buffer,
int length,
int index,
6453 nk_rune *unicode,
int *len)
6465 if (!buffer || !unicode || !len)
return 0;
6482 src_len = src_len + glyph_len;
6483 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
6485 if (i != index)
return 0;
6486 return buffer + src_len;
6494 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
6495 NK_INTERN void* nk_malloc(nk_handle unused,
void *old,nk_size size)
6497 NK_INTERN void nk_mfree(nk_handle unused,
void *ptr)
6501 nk_buffer_init_default(
struct nk_buffer *buffer)
6505 alloc.
alloc = nk_malloc;
6506 alloc.
free = nk_mfree;
6513 nk_size initial_size)
6517 NK_ASSERT(initial_size);
6518 if (!b || !a || !initial_size)
return;
6520 nk_zero(b,
sizeof(*b));
6524 b->
size = initial_size;
6535 if (!b || !m || !size)
return;
6537 nk_zero(b,
sizeof(*b));
6545 nk_buffer_align(
void *unaligned, nk_size align, nk_size *alignment,
6555 *alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
6564 *alignment = (
nk_size)((nk_byte*)unaligned - (nk_byte*)memory);
6575 nk_buffer_realloc(
struct nk_buffer *b, nk_size capacity, nk_size *size)
6588 if (!temp)
return 0;
6592 NK_MEMCPY(temp, b->
memory.
ptr, buffer_size);
6596 if (b->
size == buffer_size) {
6604 back_size = buffer_size - b->
size;
6605 dst =
nk_ptr_add(
void, temp, capacity - back_size);
6607 NK_MEMCPY(dst, src, back_size);
6608 b->
size = capacity - back_size;
6615 nk_size size, nk_size align)
6624 if (!b || !size)
return 0;
6631 memory = nk_buffer_align(unaligned, align, &alignment, type);
6648 capacity =
NK_MAX(capacity, nk_round_up_pow2((nk_uint)(b->
allocated + size)));
6656 memory = nk_buffer_align(unaligned, align, &alignment, type);
6660 else b->
size -= (size + alignment);
6668 const void *memory, nk_size size, nk_size align)
6670 void *mem = nk_buffer_alloc(b, type, size, align);
6672 NK_MEMCPY(mem, memory, size);
6679 if (!buffer)
return;
6690 if (!buffer)
return;
6735 if (!s || !b)
return;
6747 if (!buffer)
return 0;
6755 if (!buffer)
return 0;
6763 if (!buffer)
return 0;
6774 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
6776 nk_str_init_default(
struct nk_str *str)
6780 alloc.
alloc = nk_malloc;
6781 alloc.
free = nk_mfree;
6807 if (!s || !str || !len)
return 0;
6810 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
6827 if (!str || !text || !len)
return 0;
6828 for (i = 0; i < len; ++i)
6842 if (!str || !text)
return 0;
6844 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
6845 while (unicode !=
'\0' && glyph_len) {
6847 byte_len += glyph_len;
6862 if (!str || !text || !len)
return 0;
6863 for (i = 0; i < len; ++i) {
6865 if (!byte_len)
break;
6878 if (!str || !runes)
return 0;
6879 while (runes[i] !=
'\0') {
6898 NK_ASSERT(len >= 0);
6899 if (!s || !str || !len || (nk_size)pos > s->
buffer.
allocated)
return 0;
6912 NK_ASSERT(((
int)pos + (
int)len + ((
int)copylen - 1)) >= 0);
6913 NK_ASSERT(((
int)pos + ((
int)copylen - 1)) >= 0);
6916 for (i = 0; i < copylen; ++i) *dst-- = *src--;
6918 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
6934 if (!str || !cstr || !len)
return 0;
6939 if (!begin)
return 0;
6964 if (!str || !text || !len)
return 0;
6965 for (i = 0; i < len; ++i)
6979 if (!str || !text)
return 0;
6981 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
6982 while (unicode !=
'\0' && glyph_len) {
6984 byte_len += glyph_len;
6999 if (!str || !runes || !len)
return 0;
7000 for (i = 0; i < len; ++i) {
7002 if (!byte_len)
break;
7015 if (!str || !runes)
return 0;
7016 while (runes[i] !=
'\0') {
7028 NK_ASSERT(len >= 0);
7044 NK_ASSERT(len >= 0);
7045 if (!str || len < 0)
return;
7046 if (len >= str->
len) {
7051 index = str->
len - len;
7085 NK_ASSERT(s->
len >= pos + len);
7086 if (s->
len < pos + len)
7121 if (!str || !unicode || !len)
return 0;
7138 src_len = src_len + glyph_len;
7139 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7141 if (i != pos)
return 0;
7142 return text + src_len;
7166 if (!str || !unicode || !len)
return 0;
7183 src_len = src_len + glyph_len;
7184 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7186 if (i != pos)
return 0;
7187 return text + src_len;
7194 nk_rune unicode = 0;
7260 if (!cmdbuf || !buffer)
return;
7261 cmdbuf->
base = buffer;
7272 if (!buffer)
return;
7276 buffer->
clip = nk_null_rect;
7277 #ifdef NK_INCLUDE_COMMAND_USERDATA
7300 unaligned = (nk_byte*)cmd + size;
7302 alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
7303 #ifdef NK_ZERO_COMMAND_MEMORY
7304 NK_MEMSET(cmd, 0, size + alignment);
7309 #ifdef NK_INCLUDE_COMMAND_USERDATA
7331 cmd->
x = (short)r.
x;
7332 cmd->
y = (
short)r.
y;
7333 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7334 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7339 float x1,
float y1,
float line_thickness,
struct nk_color c)
7343 if (!b || line_thickness <= 0)
return;
7348 cmd->
begin.
x = (short)x0;
7349 cmd->
begin.
y = (short)y0;
7350 cmd->
end.
x = (short)x1;
7351 cmd->
end.
y = (short)y1;
7357 float ctrl0x,
float ctrl0y,
float ctrl1x,
float ctrl1y,
7358 float bx,
float by,
float line_thickness,
struct nk_color col)
7362 if (!b || col.
a == 0 || line_thickness <= 0)
return;
7368 cmd->
begin.
x = (short)ax;
7369 cmd->
begin.
y = (short)ay;
7370 cmd->
ctrl[0].
x = (short)ctrl0x;
7371 cmd->
ctrl[0].
y = (short)ctrl0y;
7372 cmd->
ctrl[1].
x = (short)ctrl1x;
7373 cmd->
ctrl[1].
y = (short)ctrl1y;
7374 cmd->
end.
x = (short)bx;
7375 cmd->
end.
y = (short)by;
7381 float rounding,
float line_thickness,
struct nk_color c)
7385 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0 || line_thickness <= 0)
return;
7389 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7394 cmd->
rounding = (
unsigned short)rounding;
7396 cmd->
x = (short)rect.
x;
7397 cmd->
y = (
short)rect.
y;
7398 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7399 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7409 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0)
return;
7413 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7419 cmd->
rounding = (
unsigned short)rounding;
7420 cmd->
x = (short)rect.
x;
7421 cmd->
y = (
short)rect.
y;
7422 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7423 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7434 if (!b || rect.
w == 0 || rect.
h == 0)
return;
7438 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7444 cmd->
x = (short)rect.
x;
7445 cmd->
y = (
short)rect.
y;
7446 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7447 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7456 float line_thickness,
struct nk_color c)
7459 if (!b || r.
w == 0 || r.
h == 0 || line_thickness <= 0)
return;
7470 cmd->
x = (short)r.
x;
7471 cmd->
y = (
short)r.
y;
7472 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
7473 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
7482 if (!b || c.
a == 0 || r.
w == 0 || r.
h == 0)
return;
7492 cmd->
x = (short)r.
x;
7493 cmd->
y = (
short)r.
y;
7494 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
7495 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
7501 float a_min,
float a_max,
float line_thickness,
struct nk_color c)
7504 if (!b || c.
a == 0 || line_thickness <= 0)
return;
7509 cmd->
cx = (short)cx;
7510 cmd->
cy = (short)cy;
7511 cmd->
r = (
unsigned short)radius;
7519 float a_min,
float a_max,
struct nk_color c)
7523 if (!b || c.
a == 0)
return;
7527 cmd->
cx = (short)cx;
7528 cmd->
cy = (short)cy;
7529 cmd->
r = (
unsigned short)radius;
7537 float y1,
float x2,
float y2,
float line_thickness,
struct nk_color c)
7541 if (!b || c.
a == 0 || line_thickness <= 0)
return;
7544 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
7545 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
7554 cmd->
a.
x = (short)x0;
7555 cmd->
a.
y = (short)y0;
7556 cmd->
b.
x = (short)x1;
7557 cmd->
b.
y = (short)y1;
7558 cmd->
c.
x = (short)x2;
7559 cmd->
c.
y = (short)y2;
7565 float y1,
float x2,
float y2,
struct nk_color c)
7569 if (!b || c.
a == 0)
return;
7573 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
7574 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
7582 cmd->
a.
x = (short)x0;
7583 cmd->
a.
y = (short)y0;
7584 cmd->
b.
x = (short)x1;
7585 cmd->
b.
y = (short)y1;
7586 cmd->
c.
x = (short)x2;
7587 cmd->
c.
y = (short)y2;
7593 float line_thickness,
struct nk_color col)
7600 if (!b || col.
a == 0 || line_thickness <= 0)
return;
7601 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7605 cmd->line_thickness = (
unsigned short)line_thickness;
7606 cmd->point_count = (
unsigned short)point_count;
7607 for (i = 0; i < point_count; ++i) {
7608 cmd->
points[i].
x = (short)points[i*2];
7609 cmd->
points[i].
y = (short)points[i*2+1];
7622 if (!b || col.
a == 0)
return;
7623 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7628 cmd->point_count = (
unsigned short)point_count;
7629 for (i = 0; i < point_count; ++i) {
7630 cmd->
points[i].
x = (short)points[i*2+0];
7631 cmd->
points[i].
y = (short)points[i*2+1];
7637 float line_thickness,
struct nk_color col)
7644 if (!b || col.
a == 0 || line_thickness <= 0)
return;
7645 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7649 cmd->point_count = (
unsigned short)point_count;
7650 cmd->line_thickness = (
unsigned short)line_thickness;
7651 for (i = 0; i < point_count; ++i) {
7652 cmd->
points[i].
x = (short)points[i*2];
7653 cmd->
points[i].
y = (short)points[i*2+1];
7673 cmd->
x = (short)r.
x;
7674 cmd->
y = (
short)r.
y;
7675 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7676 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7697 cmd->
x = (short)r.
x;
7698 cmd->
y = (
short)r.
y;
7699 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7700 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7707 const char *
string,
int length,
const struct nk_user_font *font,
7710 float text_width = 0;
7715 if (!b || !
string || !length || (bg.
a == 0 && fg.
a == 0))
return;
7724 if (text_width > r.
w){
7726 float txt_width = (float)text_width;
7727 length = nk_text_clamp(font,
string, length, r.
w, &glyphs, &txt_width, 0,0);
7730 if (!length)
return;
7734 cmd->
x = (short)r.
x;
7735 cmd->
y = (
short)r.
y;
7736 cmd->
w = (
unsigned short)r.
w;
7737 cmd->
h = (
unsigned short)r.
h;
7743 NK_MEMCPY(cmd->
string,
string, (nk_size)length);
7752 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
7754 nk_draw_list_init(
struct nk_draw_list *list)
7759 nk_zero(list,
sizeof(*list));
7760 for (i = 0; i <
NK_LEN(list->circle_vtx); ++i) {
7761 const float a = ((float)i / (
float)
NK_LEN(list->circle_vtx)) * 2 *
NK_PI;
7762 list->circle_vtx[i].x = (float)NK_COS(a);
7763 list->circle_vtx[i].y = (float)NK_SIN(a);
7775 NK_ASSERT(vertices);
7776 NK_ASSERT(elements);
7777 if (!canvas || !config || !cmds || !vertices || !elements)
7780 canvas->buffer = cmds;
7781 canvas->config = *
config;
7782 canvas->elements = elements;
7783 canvas->vertices = vertices;
7784 canvas->line_AA = line_aa;
7785 canvas->shape_AA = shape_aa;
7786 canvas->clip_rect = nk_null_rect;
7789 NK_API const struct nk_draw_command*
7790 nk__draw_list_begin(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
7794 const struct nk_draw_command *cmd;
7797 if (!buffer || !buffer->
size || !canvas->cmd_count)
7801 offset = buffer->
memory.
size - canvas->cmd_offset;
7802 cmd =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
7806 NK_API const struct nk_draw_command*
7807 nk__draw_list_end(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
7812 const struct nk_draw_command *end;
7816 if (!buffer || !canvas)
7821 offset = size - canvas->cmd_offset;
7822 end =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
7823 end -= (canvas->cmd_count-1);
7827 NK_API const struct nk_draw_command*
7828 nk__draw_list_next(
const struct nk_draw_command *cmd,
7829 const struct nk_buffer *buffer,
const struct nk_draw_list *canvas)
7831 const struct nk_draw_command *end;
7834 if (!cmd || !buffer || !canvas)
7837 end = nk__draw_list_end(canvas, buffer);
7838 if (cmd <= end)
return 0;
7843 nk_draw_list_clear(
struct nk_draw_list *list)
7854 list->element_count = 0;
7855 list->vertex_count = 0;
7856 list->cmd_offset = 0;
7857 list->cmd_count = 0;
7858 list->path_count = 0;
7861 list->clip_rect = nk_null_rect;
7865 nk_draw_list_alloc_path(
struct nk_draw_list *list,
int count)
7872 point_size * (nk_size)count, point_align);
7874 if (!points)
return 0;
7875 if (!list->path_offset) {
7877 list->path_offset = (
unsigned int)((nk_byte*)points - (nk_byte*)memory);
7879 list->path_count += (
unsigned int)count;
7884 nk_draw_list_path_last(struct nk_draw_list *list)
7888 NK_ASSERT(list->path_count);
7891 point += (list->path_count-1);
7896 nk_draw_list_push_command(
struct nk_draw_list *list,
struct nk_rect clip,
7900 NK_STORAGE const nk_size cmd_size =
sizeof(
struct nk_draw_command);
7901 struct nk_draw_command *cmd;
7904 cmd = (
struct nk_draw_command*)
7905 nk_buffer_alloc(list->buffer,
NK_BUFFER_BACK, cmd_size, cmd_align);
7908 if (!list->cmd_count) {
7912 list->cmd_offset = (
nk_size)(memory - (nk_byte*)cmd);
7915 cmd->elem_count = 0;
7916 cmd->clip_rect = clip;
7918 #ifdef NK_INCLUDE_COMMAND_USERDATA
7919 cmd->userdata = list->userdata;
7923 list->clip_rect = clip;
7928 nk_draw_list_command_last(
struct nk_draw_list *list)
7932 struct nk_draw_command *cmd;
7933 NK_ASSERT(list->cmd_count);
7937 cmd =
nk_ptr_add(
struct nk_draw_command, memory, size - list->cmd_offset);
7938 return (cmd - (list->cmd_count-1));
7942 nk_draw_list_add_clip(
struct nk_draw_list *list,
struct nk_rect rect)
7946 if (!list->cmd_count) {
7947 nk_draw_list_push_command(list, rect, list->config.null.texture);
7949 struct nk_draw_command *prev = nk_draw_list_command_last(list);
7950 if (prev->elem_count == 0)
7951 prev->clip_rect = rect;
7952 nk_draw_list_push_command(list, rect, prev->texture);
7957 nk_draw_list_push_image(
struct nk_draw_list *list, nk_handle texture)
7961 if (!list->cmd_count) {
7962 nk_draw_list_push_command(list, nk_null_rect, texture);
7964 struct nk_draw_command *prev = nk_draw_list_command_last(list);
7965 if (prev->elem_count == 0)
7968 #ifdef NK_INCLUDE_COMMAND_USERDATA
7969 prev->userdata = list->userdata;
7970 #endif // NK_INCLUDE_COMMAND_USERDATA
7972 else if (prev->texture.id != texture.
id
7974 || prev->userdata.id != list->userdata.id
7977 nk_draw_list_push_command(list, prev->clip_rect, texture);
7981 #ifdef NK_INCLUDE_COMMAND_USERDATA
7983 nk_draw_list_push_userdata(
struct nk_draw_list *list, nk_handle userdata)
7985 list->userdata = userdata;
7990 nk_draw_list_alloc_vertices(
struct nk_draw_list *list, nk_size count)
7994 if (!list)
return 0;
7996 list->config.vertex_size*count, list->config.vertex_alignment);
7998 list->vertex_count += (
unsigned int)count;
8003 nk_draw_list_alloc_elements(
struct nk_draw_list *list, nk_size count)
8006 struct nk_draw_command *cmd;
8008 NK_STORAGE const nk_size elem_size =
sizeof(nk_draw_index);
8010 if (!list)
return 0;
8012 ids = (nk_draw_index*)
8013 nk_buffer_alloc(list->elements,
NK_BUFFER_FRONT, elem_size*count, elem_align);
8015 cmd = nk_draw_list_command_last(list);
8016 list->element_count += (
unsigned int)count;
8017 cmd->elem_count += (
unsigned int)count;
8022 nk_draw_vertex_layout_element_is_end_of_layout(
8023 const struct nk_draw_vertex_layout_element *element)
8025 return (element->attribute == NK_VERTEX_ATTRIBUTE_COUNT ||
8026 element->format == NK_FORMAT_COUNT);
8030 nk_draw_vertex_color(
void *attribute,
const float *values,
8031 enum nk_draw_vertex_layout_format format)
8034 NK_ASSERT(format >= NK_FORMAT_COLOR_BEGIN);
8035 NK_ASSERT(format <= NK_FORMAT_COLOR_END);
8036 if (format < NK_FORMAT_COLOR_BEGIN || format > NK_FORMAT_COLOR_END)
return;
8039 default: NK_ASSERT(0 &&
"Invalid vertex layout color format");
break;
8040 case NK_FORMAT_R8G8B8A8:
8041 case NK_FORMAT_R8G8B8: {
8043 NK_MEMCPY(attribute, &col.
r,
sizeof(col));
8045 case NK_FORMAT_B8G8R8A8: {
8048 NK_MEMCPY(attribute, &bgra,
sizeof(bgra));
8050 case NK_FORMAT_R16G15B16: {
8052 col[0] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
8053 col[1] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
8054 col[2] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
8055 NK_MEMCPY(attribute, col,
sizeof(col));
8057 case NK_FORMAT_R16G15B16A16: {
8059 col[0] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
8060 col[1] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
8061 col[2] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
8062 col[3] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[3] * NK_USHORT_MAX, NK_USHORT_MAX);
8063 NK_MEMCPY(attribute, col,
sizeof(col));
8065 case NK_FORMAT_R32G32B32: {
8067 col[0] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
8068 col[1] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
8069 col[2] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
8070 NK_MEMCPY(attribute, col,
sizeof(col));
8072 case NK_FORMAT_R32G32B32A32: {
8074 col[0] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
8075 col[1] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
8076 col[2] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
8077 col[3] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[3] * NK_UINT_MAX, NK_UINT_MAX);
8078 NK_MEMCPY(attribute, col,
sizeof(col));
8080 case NK_FORMAT_R32G32B32A32_FLOAT:
8081 NK_MEMCPY(attribute, values,
sizeof(
float)*4);
8083 case NK_FORMAT_R32G32B32A32_DOUBLE: {
8089 NK_MEMCPY(attribute, col,
sizeof(col));
8091 case NK_FORMAT_RGB32:
8092 case NK_FORMAT_RGBA32: {
8095 NK_MEMCPY(attribute, &color,
sizeof(color));
8101 nk_draw_vertex_element(
void *dst,
const float *values,
int value_count,
8102 enum nk_draw_vertex_layout_format format)
8105 void *attribute = dst;
8107 NK_ASSERT(format < NK_FORMAT_COLOR_BEGIN);
8108 if (format >= NK_FORMAT_COLOR_BEGIN && format <= NK_FORMAT_COLOR_END)
return;
8109 for (value_index = 0; value_index < value_count; ++value_index) {
8111 default: NK_ASSERT(0 &&
"invalid vertex layout format");
break;
8112 case NK_FORMAT_SCHAR: {
8113 char value = (char)
NK_CLAMP(NK_SCHAR_MIN, values[value_index], NK_SCHAR_MAX);
8114 NK_MEMCPY(attribute, &value,
sizeof(value));
8115 attribute = (
void*)((
char*)attribute +
sizeof(char));
8117 case NK_FORMAT_SSHORT: {
8118 nk_short value = (
nk_short)
NK_CLAMP(NK_SSHORT_MIN, values[value_index], NK_SSHORT_MAX);
8119 NK_MEMCPY(attribute, &value,
sizeof(value));
8120 attribute = (
void*)((
char*)attribute +
sizeof(
value));
8122 case NK_FORMAT_SINT: {
8123 nk_int value = (
nk_int)
NK_CLAMP(NK_SINT_MIN, values[value_index], NK_SINT_MAX);
8124 NK_MEMCPY(attribute, &value,
sizeof(value));
8125 attribute = (
void*)((
char*)attribute +
sizeof(
nk_int));
8127 case NK_FORMAT_UCHAR: {
8128 unsigned char value = (
unsigned char)
NK_CLAMP(NK_UCHAR_MIN, values[value_index], NK_UCHAR_MAX);
8129 NK_MEMCPY(attribute, &value,
sizeof(value));
8130 attribute = (
void*)((
char*)attribute +
sizeof(
unsigned char));
8132 case NK_FORMAT_USHORT: {
8133 nk_ushort value = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[value_index], NK_USHORT_MAX);
8134 NK_MEMCPY(attribute, &value,
sizeof(value));
8135 attribute = (
void*)((
char*)attribute +
sizeof(
value));
8137 case NK_FORMAT_UINT: {
8138 nk_uint value = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[value_index], NK_UINT_MAX);
8139 NK_MEMCPY(attribute, &value,
sizeof(value));
8140 attribute = (
void*)((
char*)attribute +
sizeof(
nk_uint));
8142 case NK_FORMAT_FLOAT:
8143 NK_MEMCPY(attribute, &values[value_index],
sizeof(values[value_index]));
8144 attribute = (
void*)((
char*)attribute +
sizeof(float));
8146 case NK_FORMAT_DOUBLE: {
8147 double value = (double)values[value_index];
8148 NK_MEMCPY(attribute, &value,
sizeof(value));
8149 attribute = (
void*)((
char*)attribute +
sizeof(double));
8159 void *result = (
void*)((
char*)dst + config->
vertex_size);
8160 const struct nk_draw_vertex_layout_element *elem_iter = config->
vertex_layout;
8161 while (!nk_draw_vertex_layout_element_is_end_of_layout(elem_iter)) {
8162 void *address = (
void*)((
char*)dst + elem_iter->offset);
8163 switch (elem_iter->attribute) {
8164 case NK_VERTEX_ATTRIBUTE_COUNT:
8165 default: NK_ASSERT(0 &&
"wrong element attribute");
8166 case NK_VERTEX_POSITION: nk_draw_vertex_element(address, &pos.
x, 2, elem_iter->format);
break;
8167 case NK_VERTEX_TEXCOORD: nk_draw_vertex_element(address, &uv.
x, 2, elem_iter->format);
break;
8168 case NK_VERTEX_COLOR: nk_draw_vertex_color(address, &color.
r, elem_iter->format);
break;
8176 nk_draw_list_stroke_poly_line(
struct nk_draw_list *list,
const struct nk_vec2 *points,
8177 const unsigned int points_count,
struct nk_color color,
enum nk_draw_list_stroke closed,
8185 if (!list || points_count < 2)
return;
8187 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8188 count = points_count;
8189 if (!closed) count = points_count-1;
8190 thick_line = thickness > 1.0f;
8192 #ifdef NK_INCLUDE_COMMAND_USERDATA
8193 nk_draw_list_push_userdata(list, list->userdata);
8196 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8203 const float AA_SIZE = 1.0f;
8209 nk_size vertex_offset;
8210 nk_size index = list->vertex_count;
8212 const nk_size idx_count = (thick_line) ? (count * 18) : (count * 12);
8213 const nk_size vtx_count = (thick_line) ? (points_count * 4): (points_count *3);
8215 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8216 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8219 struct nk_vec2 *normals, *temp;
8220 if (!vtx || !ids)
return;
8223 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
8225 size = pnt_size * ((thick_line) ? 5 : 3) * points_count;
8228 if (!normals)
return;
8229 temp = normals + points_count;
8232 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
8235 for (i1 = 0; i1 < count; ++i1) {
8236 const nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
8243 len = nk_inv_sqrt(len);
8247 normals[i1].
x = diff.
y;
8248 normals[i1].
y = -diff.
x;
8252 normals[points_count-1] = normals[points_count-2];
8261 temp[(points_count-1) * 2 + 0] =
nk_vec2_add(points[points_count-1], d);
8262 temp[(points_count-1) * 2 + 1] =
nk_vec2_sub(points[points_count-1], d);
8267 for (i1 = 0; i1 < count; i1++) {
8270 nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
8271 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 3);
8275 dmr2 = dm.x * dm.x + dm.y* dm.y;
8276 if (dmr2 > 0.000001f) {
8277 float scale = 1.0f/dmr2;
8278 scale =
NK_MIN(100.0f, scale);
8286 ids[0] = (nk_draw_index)(idx2 + 0); ids[1] = (nk_draw_index)(idx1+0);
8287 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
8288 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+0);
8289 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
8290 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
8291 ids[10]= (nk_draw_index)(idx2 + 0); ids[11]= (nk_draw_index)(idx2+1);
8297 for (i = 0; i < points_count; ++i) {
8298 const struct nk_vec2 uv = list->config.null.uv;
8299 vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col);
8300 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans);
8301 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans);
8305 const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
8315 d1 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness + AA_SIZE);
8316 d2 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness);
8318 temp[(points_count-1)*4+0] =
nk_vec2_add(points[points_count-1], d1);
8319 temp[(points_count-1)*4+1] =
nk_vec2_add(points[points_count-1], d2);
8320 temp[(points_count-1)*4+2] =
nk_vec2_sub(points[points_count-1], d2);
8321 temp[(points_count-1)*4+3] =
nk_vec2_sub(points[points_count-1], d1);
8326 for (i1 = 0; i1 < count; ++i1) {
8328 const nk_size i2 = ((i1+1) == points_count) ? 0: (i1 + 1);
8329 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 4);
8333 float dmr2 = dm.
x * dm.
x + dm.
y* dm.
y;
8334 if (dmr2 > 0.000001f) {
8335 float scale = 1.0f/dmr2;
8336 scale =
NK_MIN(100.0f, scale);
8340 dm_out =
nk_vec2_muls(dm, ((half_inner_thickness) + AA_SIZE));
8348 ids[0] = (nk_draw_index)(idx2 + 1); ids[1] = (nk_draw_index)(idx1+1);
8349 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
8350 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+1);
8351 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
8352 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
8353 ids[10]= (nk_draw_index)(idx2 + 0); ids[11] = (nk_draw_index)(idx2+1);
8354 ids[12]= (nk_draw_index)(idx2 + 2); ids[13] = (nk_draw_index)(idx1+2);
8355 ids[14]= (nk_draw_index)(idx1 + 3); ids[15] = (nk_draw_index)(idx1+3);
8356 ids[16]= (nk_draw_index)(idx2 + 3); ids[17] = (nk_draw_index)(idx2+2);
8362 for (i = 0; i < points_count; ++i) {
8363 const struct nk_vec2 uv = list->config.null.uv;
8364 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans);
8365 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col);
8366 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col);
8367 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+3], uv, col_trans);
8375 nk_size idx = list->vertex_count;
8376 const nk_size idx_count = count * 6;
8377 const nk_size vtx_count = count * 4;
8378 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8379 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8380 if (!vtx || !ids)
return;
8382 for (i1 = 0; i1 < count; ++i1) {
8384 const struct nk_vec2 uv = list->config.null.uv;
8385 const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1;
8386 const struct nk_vec2 p1 = points[i1];
8387 const struct nk_vec2 p2 = points[i2];
8394 len = nk_inv_sqrt(len);
8399 dx = diff.
x * (thickness * 0.5f);
8400 dy = diff.
y * (thickness * 0.5f);
8402 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x + dy, p1.
y - dx), uv, col);
8403 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x + dy, p2.
y - dx), uv, col);
8404 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x - dy, p2.
y + dx), uv, col);
8405 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x - dy, p1.
y + dx), uv, col);
8407 ids[0] = (nk_draw_index)(idx+0); ids[1] = (nk_draw_index)(idx+1);
8408 ids[2] = (nk_draw_index)(idx+2); ids[3] = (nk_draw_index)(idx+0);
8409 ids[4] = (nk_draw_index)(idx+2); ids[5] = (nk_draw_index)(idx+3);
8418 nk_draw_list_fill_poly_convex(
struct nk_draw_list *list,
8419 const struct nk_vec2 *points,
const unsigned int points_count,
8428 if (!list || points_count < 3)
return;
8430 #ifdef NK_INCLUDE_COMMAND_USERDATA
8431 nk_draw_list_push_userdata(list, list->userdata);
8434 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8444 const float AA_SIZE = 1.0f;
8445 nk_size vertex_offset = 0;
8446 nk_size index = list->vertex_count;
8448 const nk_size idx_count = (points_count-2)*3 + points_count*6;
8449 const nk_size vtx_count = (points_count*2);
8451 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8452 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8456 unsigned int vtx_inner_idx = (
unsigned int)(index + 0);
8457 unsigned int vtx_outer_idx = (
unsigned int)(index + 1);
8458 if (!vtx || !ids)
return;
8461 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
8463 size = pnt_size * points_count;
8466 if (!normals)
return;
8467 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
8470 for (i = 2; i < points_count; i++) {
8471 ids[0] = (nk_draw_index)(vtx_inner_idx);
8472 ids[1] = (nk_draw_index)(vtx_inner_idx + ((i-1) << 1));
8473 ids[2] = (nk_draw_index)(vtx_inner_idx + (i << 1));
8478 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
8479 struct nk_vec2 p0 = points[i0];
8480 struct nk_vec2 p1 = points[i1];
8486 len = nk_inv_sqrt(len);
8490 normals[i0].
x = diff.
y;
8491 normals[i0].
y = -diff.
x;
8495 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
8496 const struct nk_vec2 uv = list->config.null.uv;
8497 struct nk_vec2 n0 = normals[i0];
8498 struct nk_vec2 n1 = normals[i1];
8500 float dmr2 = dm.
x*dm.
x + dm.
y*dm.
y;
8501 if (dmr2 > 0.000001f) {
8502 float scale = 1.0f / dmr2;
8503 scale =
NK_MIN(scale, 100.0f);
8509 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_sub(points[i1], dm), uv, col);
8510 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_add(points[i1], dm), uv, col_trans);
8513 ids[0] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
8514 ids[1] = (nk_draw_index)(vtx_inner_idx+(i0<<1));
8515 ids[2] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
8516 ids[3] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
8517 ids[4] = (nk_draw_index)(vtx_outer_idx+(i1<<1));
8518 ids[5] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
8525 nk_size index = list->vertex_count;
8526 const nk_size idx_count = (points_count-2)*3;
8527 const nk_size vtx_count = points_count;
8528 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8529 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8531 if (!vtx || !ids)
return;
8532 for (i = 0; i < vtx_count; ++i)
8533 vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col);
8534 for (i = 2; i < points_count; ++i) {
8535 ids[0] = (nk_draw_index)index;
8536 ids[1] = (nk_draw_index)(index+ i - 1);
8537 ids[2] = (nk_draw_index)(index+i);
8544 nk_draw_list_path_clear(
struct nk_draw_list *list)
8549 list->path_count = 0;
8550 list->path_offset = 0;
8554 nk_draw_list_path_line_to(
struct nk_draw_list *list,
struct nk_vec2 pos)
8557 struct nk_draw_command *cmd = 0;
8560 if (!list->cmd_count)
8561 nk_draw_list_add_clip(list, nk_null_rect);
8563 cmd = nk_draw_list_command_last(list);
8564 if (cmd && cmd->texture.ptr != list->config.null.texture.ptr)
8565 nk_draw_list_push_image(list, list->config.null.texture);
8567 points = nk_draw_list_alloc_path(list, 1);
8568 if (!points)
return;
8573 nk_draw_list_path_arc_to_fast(
struct nk_draw_list *list,
struct nk_vec2 center,
8574 float radius,
int a_min,
int a_max)
8579 if (a_min <= a_max) {
8580 for (a = a_min; a <= a_max; a++) {
8582 const float x = center.
x + c.
x * radius;
8583 const float y = center.
y + c.
y * radius;
8584 nk_draw_list_path_line_to(list,
nk_vec2(x, y));
8590 nk_draw_list_path_arc_to(
struct nk_draw_list *list,
struct nk_vec2 center,
8591 float radius,
float a_min,
float a_max,
unsigned int segments)
8596 if (radius == 0.0f)
return;
8616 const float d_angle = (a_max - a_min) / (
float)segments;
8617 const float sin_d = (float)NK_SIN(d_angle);
8618 const float cos_d = (float)NK_COS(d_angle);
8620 float cx = (float)NK_COS(a_min) * radius;
8621 float cy = (float)NK_SIN(a_min) * radius;
8622 for(i = 0; i <= segments; ++i) {
8623 const float x = center.
x + cx;
8624 const float y = center.
y + cy;
8625 nk_draw_list_path_line_to(list,
nk_vec2(x, y));
8627 const float new_cx = cx * cos_d - cy * sin_d;
8628 const float new_cy = cy * cos_d + cx * sin_d;
8635 nk_draw_list_path_rect_to(
struct nk_draw_list *list,
struct nk_vec2 a,
8636 struct nk_vec2 b,
float rounding)
8642 r =
NK_MIN(r, ((b.
x-a.
x) < 0) ? -(b.
x-a.
x): (b.
x-a.
x));
8643 r =
NK_MIN(r, ((b.
y-a.
y) < 0) ? -(b.
y-a.
y): (b.
y-a.
y));
8646 nk_draw_list_path_line_to(list, a);
8647 nk_draw_list_path_line_to(list,
nk_vec2(b.
x,a.
y));
8648 nk_draw_list_path_line_to(list, b);
8649 nk_draw_list_path_line_to(list,
nk_vec2(a.
x,b.
y));
8651 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.
x + r, a.
y + r), r, 6, 9);
8652 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.
x - r, a.
y + r), r, 9, 12);
8653 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.
x - r, b.
y - r), r, 0, 3);
8654 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.
x + r, b.
y - r), r, 3, 6);
8659 nk_draw_list_path_curve_to(
struct nk_draw_list *list,
struct nk_vec2 p2,
8663 unsigned int i_step;
8667 NK_ASSERT(list->path_count);
8668 if (!list || !list->path_count)
return;
8669 num_segments =
NK_MAX(num_segments, 1);
8671 p1 = nk_draw_list_path_last(list);
8672 t_step = 1.0f/(float)num_segments;
8673 for (i_step = 1; i_step <= num_segments; ++i_step) {
8674 float t = t_step * (float)i_step;
8679 float w4 = t * t *t;
8680 float x = w1 * p1.
x + w2 * p2.
x + w3 * p3.
x + w4 * p4.
x;
8681 float y = w1 * p1.
y + w2 * p2.
y + w3 * p3.
y + w4 * p4.
y;
8682 nk_draw_list_path_line_to(list,
nk_vec2(x,y));
8687 nk_draw_list_path_fill(
struct nk_draw_list *list,
struct nk_color color)
8693 nk_draw_list_fill_poly_convex(list, points, list->path_count, color, list->config.shape_AA);
8694 nk_draw_list_path_clear(list);
8698 nk_draw_list_path_stroke(
struct nk_draw_list *list,
struct nk_color color,
8699 enum nk_draw_list_stroke closed,
float thickness)
8705 nk_draw_list_stroke_poly_line(list, points, list->path_count, color,
8706 closed, thickness, list->config.line_AA);
8707 nk_draw_list_path_clear(list);
8711 nk_draw_list_stroke_line(
struct nk_draw_list *list,
struct nk_vec2 a,
8715 if (!list || !col.
a)
return;
8717 nk_draw_list_path_line_to(list, a);
8718 nk_draw_list_path_line_to(list, b);
8723 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
8727 nk_draw_list_fill_rect(
struct nk_draw_list *list,
struct nk_rect rect,
8728 struct nk_color col,
float rounding)
8731 if (!list || !col.
a)
return;
8734 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x, rect.
y),
8735 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
8737 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x-0.5f, rect.
y-0.5f),
8738 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
8739 } nk_draw_list_path_fill(list, col);
8743 nk_draw_list_stroke_rect(
struct nk_draw_list *list,
struct nk_rect rect,
8744 struct nk_color col,
float rounding,
float thickness)
8747 if (!list || !col.
a)
return;
8749 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x, rect.
y),
8750 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
8752 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x-0.5f, rect.
y-0.5f),
8753 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
8754 } nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8758 nk_draw_list_fill_rect_multi_color(
struct nk_draw_list *list,
struct nk_rect rect,
8766 nk_draw_index index;
8776 nk_draw_list_push_image(list, list->config.null.texture);
8777 index = (nk_draw_index)list->vertex_count;
8778 vtx = nk_draw_list_alloc_vertices(list, 4);
8779 idx = nk_draw_list_alloc_elements(list, 6);
8780 if (!vtx || !idx)
return;
8782 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
8783 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
8784 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
8786 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y), list->config.null.uv, col_left);
8787 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y), list->config.null.uv, col_top);
8788 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), list->config.null.uv, col_right);
8789 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y + rect.
h), list->config.null.uv, col_bottom);
8793 nk_draw_list_fill_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
8797 if (!list || !col.
a)
return;
8798 nk_draw_list_path_line_to(list, a);
8799 nk_draw_list_path_line_to(list, b);
8800 nk_draw_list_path_line_to(list, c);
8801 nk_draw_list_path_fill(list, col);
8805 nk_draw_list_stroke_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
8809 if (!list || !col.
a)
return;
8810 nk_draw_list_path_line_to(list, a);
8811 nk_draw_list_path_line_to(list, b);
8812 nk_draw_list_path_line_to(list, c);
8813 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8817 nk_draw_list_fill_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
8818 float radius,
struct nk_color col,
unsigned int segs)
8822 if (!list || !col.
a)
return;
8823 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
8824 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
8825 nk_draw_list_path_fill(list, col);
8829 nk_draw_list_stroke_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
8830 float radius,
struct nk_color col,
unsigned int segs,
float thickness)
8834 if (!list || !col.
a)
return;
8835 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
8836 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
8837 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8841 nk_draw_list_stroke_curve(
struct nk_draw_list *list,
struct nk_vec2 p0,
8843 struct nk_color col,
unsigned int segments,
float thickness)
8846 if (!list || !col.
a)
return;
8847 nk_draw_list_path_line_to(list, p0);
8848 nk_draw_list_path_curve_to(list, cp0, cp1, p1, segments);
8849 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
8853 nk_draw_list_push_rect_uv(
struct nk_draw_list *list,
struct nk_vec2 a,
8865 nk_draw_index index;
8875 index = (nk_draw_index)list->vertex_count;
8876 vtx = nk_draw_list_alloc_vertices(list, 4);
8877 idx = nk_draw_list_alloc_elements(list, 6);
8878 if (!vtx || !idx)
return;
8880 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
8881 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
8882 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
8884 vtx = nk_draw_vertex(vtx, &list->config, a, uva, col);
8885 vtx = nk_draw_vertex(vtx, &list->config, b, uvb, col);
8886 vtx = nk_draw_vertex(vtx, &list->config, c, uvc, col);
8887 vtx = nk_draw_vertex(vtx, &list->config, d, uvd, col);
8891 nk_draw_list_add_image(
struct nk_draw_list *list,
struct nk_image texture,
8897 nk_draw_list_push_image(list, texture.
handle);
8901 uv[0].
x = (float)texture.
region[0]/(
float)texture.
w;
8902 uv[0].
y = (float)texture.
region[1]/(
float)texture.
h;
8903 uv[1].
x = (float)(texture.
region[0] + texture.
region[2])/(float)texture.
w;
8904 uv[1].
y = (
float)(texture.
region[1] + texture.
region[3])/(
float)texture.
h;
8905 nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
8906 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), uv[0], uv[1], color);
8907 }
else nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
8913 nk_draw_list_add_text(
struct nk_draw_list *list,
const struct nk_user_font *font,
8914 struct nk_rect rect,
const char *text,
int len,
float font_height,
8919 nk_rune unicode = 0;
8922 int next_glyph_len = 0;
8923 struct nk_user_font_glyph g;
8926 if (!list || !len || !text)
return;
8928 list->clip_rect.x, list->clip_rect.y, list->clip_rect.w, list->clip_rect.h))
return;
8930 nk_draw_list_push_image(list, font->texture);
8933 if (!glyph_len)
return;
8936 fg.
a = (
nk_byte)((
float)fg.
a * list->config.global_alpha);
8937 while (text_len < len && glyph_len) {
8938 float gx, gy, gh, gw;
8939 float char_width = 0;
8943 next_glyph_len =
nk_utf_decode(text + text_len + glyph_len, &next, (
int)len - text_len);
8944 font->query(font->
userdata, font_height, &g, unicode,
8948 gx = x + g.offset.x;
8949 gy = rect.
y + g.offset.y;
8950 gw = g.width; gh = g.height;
8951 char_width = g.xadvance;
8952 nk_draw_list_push_rect_uv(list,
nk_vec2(gx,gy),
nk_vec2(gx + gw, gy+ gh),
8953 g.uv[0], g.uv[1], fg);
8956 text_len += glyph_len;
8958 glyph_len = next_glyph_len;
8972 NK_ASSERT(vertices);
8973 NK_ASSERT(elements);
8977 if (!ctx || !cmds || !vertices || !elements || !config || !config->
vertex_layout)
8980 nk_draw_list_setup(&ctx->draw_list, config, cmds, vertices, elements,
8984 #ifdef NK_INCLUDE_COMMAND_USERDATA
8985 ctx->draw_list.userdata = cmd->userdata;
8987 switch (cmd->
type) {
8991 nk_draw_list_add_clip(&ctx->draw_list,
nk_rect(s->
x, s->
y, s->
w, s->
h));
9007 nk_draw_list_stroke_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
9012 nk_draw_list_fill_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
9017 nk_draw_list_fill_rect_multi_color(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
9022 nk_draw_list_stroke_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
9023 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
9028 nk_draw_list_fill_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
9029 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
9034 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
9035 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
9041 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
9042 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
9044 nk_draw_list_path_fill(&ctx->draw_list, c->
color);
9048 nk_draw_list_stroke_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
9054 nk_draw_list_fill_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
9062 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
9071 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
9073 nk_draw_list_path_fill(&ctx->draw_list, p->
color);
9080 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
9086 nk_draw_list_add_text(&ctx->draw_list, t->
font,
nk_rect(t->
x, t->
y, t->
w, t->
h),
9091 nk_draw_list_add_image(&ctx->draw_list, i->
img,
nk_rect(i->
x, i->
y, i->
w, i->
h), i->
col);
9105 NK_API const struct nk_draw_command*
9108 {
return nk__draw_list_begin(&ctx->draw_list, buffer);}
9110 NK_API const struct nk_draw_command*
9112 {
return nk__draw_list_end(&ctx->draw_list, buffer);}
9114 NK_API const struct nk_draw_command*
9115 nk__draw_next(
const struct nk_draw_command *cmd,
9117 {
return nk__draw_list_next(cmd, buffer, &ctx->draw_list);}
9128 #ifdef NK_INCLUDE_FONT_BAKING
9136 #define NK_RP__MAXVAL 0xffff
9137 typedef unsigned short nk_rp_coord;
9152 struct nk_rp_node *next;
9155 struct nk_rp_context {
9162 struct nk_rp_node *active_head;
9163 struct nk_rp_node *free_head;
9164 struct nk_rp_node extra[2];
9168 struct nk_rp__findresult {
9170 struct nk_rp_node **prev_link;
9173 enum NK_RP_HEURISTIC {
9174 NK_RP_HEURISTIC_Skyline_default=0,
9175 NK_RP_HEURISTIC_Skyline_BL_sortHeight = NK_RP_HEURISTIC_Skyline_default,
9176 NK_RP_HEURISTIC_Skyline_BF_sortHeight
9178 enum NK_RP_INIT_STATE{NK_RP__INIT_skyline = 1};
9181 nk_rp_setup_allow_out_of_mem(
struct nk_rp_context *context,
int allow_out_of_mem)
9183 if (allow_out_of_mem)
9196 context->align = (context->width + context->num_nodes-1) / context->num_nodes;
9201 nk_rp_init_target(
struct nk_rp_context *context,
int width,
int height,
9202 struct nk_rp_node *nodes,
int num_nodes)
9205 #ifndef STBRP_LARGE_RECTS
9206 NK_ASSERT(width <= 0xffff && height <= 0xffff);
9209 for (i=0; i < num_nodes-1; ++i)
9210 nodes[i].next = &nodes[i+1];
9212 context->init_mode = NK_RP__INIT_skyline;
9213 context->heuristic = NK_RP_HEURISTIC_Skyline_default;
9214 context->free_head = &nodes[0];
9215 context->active_head = &context->extra[0];
9216 context->width = width;
9217 context->height = height;
9218 context->num_nodes = num_nodes;
9219 nk_rp_setup_allow_out_of_mem(context, 0);
9222 context->extra[0].x = 0;
9223 context->extra[0].y = 0;
9224 context->extra[0].next = &context->extra[1];
9225 context->extra[1].x = (nk_rp_coord) width;
9226 context->extra[1].y = 65535;
9227 context->extra[1].next = 0;
9232 nk_rp__skyline_find_min_y(
struct nk_rp_context *c,
struct nk_rp_node *first,
9233 int x0,
int width,
int *pwaste)
9235 struct nk_rp_node *node = first;
9236 int x1 = x0 + width;
9237 int min_y, visited_width, waste_area;
9238 NK_ASSERT(first->x <= x0);
9241 NK_ASSERT(node->next->x > x0);
9243 NK_ASSERT(node->x <= x0);
9248 while (node->x < x1)
9250 if (node->y > min_y) {
9254 waste_area += visited_width * (node->y - min_y);
9258 visited_width += node->next->x - x0;
9260 visited_width += node->next->x - node->x;
9263 int under_width = node->next->x - node->x;
9264 if (under_width + visited_width > width)
9265 under_width = width - visited_width;
9266 waste_area += under_width * (min_y - node->y);
9267 visited_width += under_width;
9271 *pwaste = waste_area;
9276 nk_rp__skyline_find_best_pos(struct nk_rp_context *c,
int width,
int height)
9278 int best_waste = (1<<30), best_x, best_y = (1 << 30);
9279 struct nk_rp__findresult fr;
9280 struct nk_rp_node **prev, *node, *tail, **best = 0;
9283 width = (width + c->align - 1);
9284 width -= width % c->align;
9285 NK_ASSERT(width % c->align == 0);
9287 node = c->active_head;
9288 prev = &c->active_head;
9289 while (node->x + width <= c->width) {
9291 y = nk_rp__skyline_find_min_y(c, node, node->x, width, &waste);
9293 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BL_sortHeight) {
9301 if (y + height <= c->height) {
9303 if (y < best_y || (y == best_y && waste < best_waste)) {
9313 best_x = (best == 0) ? 0 : (*best)->x;
9331 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BF_sortHeight)
9333 tail = c->active_head;
9334 node = c->active_head;
9335 prev = &c->active_head;
9337 while (tail->x < width)
9341 int xpos = tail->x - width;
9343 NK_ASSERT(xpos >= 0);
9345 while (node->next->x <= xpos) {
9349 NK_ASSERT(node->next->x > xpos && node->x <= xpos);
9350 y = nk_rp__skyline_find_min_y(c, node, xpos, width, &waste);
9351 if (y + height < c->height) {
9353 if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
9355 NK_ASSERT(y <= best_y);
9365 fr.prev_link = best;
9372 nk_rp__skyline_pack_rectangle(struct nk_rp_context *context,
int width,
int height)
9375 struct nk_rp__findresult res = nk_rp__skyline_find_best_pos(context, width, height);
9376 struct nk_rp_node *node, *cur;
9382 if (res.prev_link == 0 || res.y + height > context->height || context->free_head == 0) {
9388 node = context->free_head;
9389 node->x = (nk_rp_coord) res.x;
9390 node->y = (nk_rp_coord) (res.y + height);
9392 context->free_head = node->next;
9397 cur = *res.prev_link;
9398 if (cur->x < res.x) {
9400 struct nk_rp_node *next = cur->next;
9404 *res.prev_link = node;
9409 while (cur->next && cur->next->x <= res.x + width) {
9410 struct nk_rp_node *next = cur->next;
9412 cur->next = context->free_head;
9413 context->free_head = cur;
9419 if (cur->x < res.x + width)
9420 cur->x = (nk_rp_coord) (res.x + width);
9425 nk_rect_height_compare(
const void *a,
const void *b)
9427 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
9428 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
9433 return (p->w > q->w) ? -1 : (p->w < q->w);
9437 nk_rect_original_order(
const void *a,
const void *b)
9439 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
9440 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
9441 return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
9445 nk_rp_qsort(
struct nk_rp_rect *array,
unsigned int len,
int(*cmp)(
const void*,
const void*))
9448 #define NK_MAX_SORT_STACK 64
9449 unsigned right, left = 0, stack[NK_MAX_SORT_STACK], pos = 0;
9450 unsigned seed = len/2 * 69069+1;
9452 for (; left+1 < len; len++) {
9453 struct nk_rp_rect pivot, tmp;
9454 if (pos == NK_MAX_SORT_STACK) len = stack[pos = 0];
9455 pivot = array[left+seed%(len-left)];
9456 seed = seed * 69069 + 1;
9458 for (right = left-1;;) {
9459 while (cmp(&array[++right], &pivot) < 0);
9460 while (cmp(&pivot, &array[--len]) < 0);
9461 if (right >= len)
break;
9463 array[right] = array[len];
9467 if (pos == 0)
break;
9471 #undef NK_MAX_SORT_STACK
9475 nk_rp_pack_rects(
struct nk_rp_context *context,
struct nk_rp_rect *rects,
int num_rects)
9479 for (i=0; i < num_rects; ++i) {
9480 rects[i].was_packed = i;
9484 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_height_compare);
9486 for (i=0; i < num_rects; ++i) {
9487 struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
9489 rects[i].x = (nk_rp_coord) fr.x;
9490 rects[i].y = (nk_rp_coord) fr.y;
9492 rects[i].x = rects[i].y = NK_RP__MAXVAL;
9497 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_original_order);
9500 for (i=0; i < num_rects; ++i)
9501 rects[i].was_packed = !(rects[i].x == NK_RP__MAXVAL && rects[i].y == NK_RP__MAXVAL);
9512 #define NK_TT_MAX_OVERSAMPLE 8
9513 #define NK_TT__OVER_MASK (NK_TT_MAX_OVERSAMPLE-1)
9515 struct nk_tt_bakedchar {
9516 unsigned short x0,y0,x1,y1;
9518 float xoff,yoff,xadvance;
9521 struct nk_tt_aligned_quad{
9526 struct nk_tt_packedchar {
9527 unsigned short x0,y0,x1,y1;
9529 float xoff,yoff,xadvance;
9533 struct nk_tt_pack_range {
9535 int first_unicode_codepoint_in_range;
9537 int *array_of_unicode_codepoints;
9540 struct nk_tt_packedchar *chardata_for_range;
9541 unsigned char h_oversample, v_oversample;
9545 struct nk_tt_pack_context {
9549 int stride_in_bytes;
9551 unsigned int h_oversample, v_oversample;
9552 unsigned char *pixels;
9556 struct nk_tt_fontinfo {
9557 const unsigned char* data;
9560 int loca,head,glyf,hhea,hmtx,kern;
9562 int indexToLocFormat;
9571 struct nk_tt_vertex {
9573 unsigned char type,padding;
9576 struct nk_tt__bitmap{
9578 unsigned char *pixels;
9581 struct nk_tt__hheap_chunk {
9582 struct nk_tt__hheap_chunk *next;
9584 struct nk_tt__hheap {
9586 struct nk_tt__hheap_chunk *head;
9588 int num_remaining_in_head_chunk;
9591 struct nk_tt__edge {
9596 struct nk_tt__active_edge {
9597 struct nk_tt__active_edge *next;
9603 struct nk_tt__point {
float x,y;};
9605 #define NK_TT_MACSTYLE_DONTCARE 0
9606 #define NK_TT_MACSTYLE_BOLD 1
9607 #define NK_TT_MACSTYLE_ITALIC 2
9608 #define NK_TT_MACSTYLE_UNDERSCORE 4
9609 #define NK_TT_MACSTYLE_NONE 8
9613 NK_TT_PLATFORM_ID_UNICODE =0,
9614 NK_TT_PLATFORM_ID_MAC =1,
9615 NK_TT_PLATFORM_ID_ISO =2,
9616 NK_TT_PLATFORM_ID_MICROSOFT =3
9620 NK_TT_UNICODE_EID_UNICODE_1_0 =0,
9621 NK_TT_UNICODE_EID_UNICODE_1_1 =1,
9622 NK_TT_UNICODE_EID_ISO_10646 =2,
9623 NK_TT_UNICODE_EID_UNICODE_2_0_BMP=3,
9624 NK_TT_UNICODE_EID_UNICODE_2_0_FULL=4
9628 NK_TT_MS_EID_SYMBOL =0,
9629 NK_TT_MS_EID_UNICODE_BMP =1,
9630 NK_TT_MS_EID_SHIFTJIS =2,
9631 NK_TT_MS_EID_UNICODE_FULL =10
9635 NK_TT_MAC_EID_ROMAN =0, NK_TT_MAC_EID_ARABIC =4,
9636 NK_TT_MAC_EID_JAPANESE =1, NK_TT_MAC_EID_HEBREW =5,
9637 NK_TT_MAC_EID_CHINESE_TRAD =2, NK_TT_MAC_EID_GREEK =6,
9638 NK_TT_MAC_EID_KOREAN =3, NK_TT_MAC_EID_RUSSIAN =7
9643 NK_TT_MS_LANG_ENGLISH =0x0409, NK_TT_MS_LANG_ITALIAN =0x0410,
9644 NK_TT_MS_LANG_CHINESE =0x0804, NK_TT_MS_LANG_JAPANESE =0x0411,
9645 NK_TT_MS_LANG_DUTCH =0x0413, NK_TT_MS_LANG_KOREAN =0x0412,
9646 NK_TT_MS_LANG_FRENCH =0x040c, NK_TT_MS_LANG_RUSSIAN =0x0419,
9647 NK_TT_MS_LANG_GERMAN =0x0407, NK_TT_MS_LANG_SPANISH =0x0409,
9648 NK_TT_MS_LANG_HEBREW =0x040d, NK_TT_MS_LANG_SWEDISH =0x041D
9652 NK_TT_MAC_LANG_ENGLISH =0 , NK_TT_MAC_LANG_JAPANESE =11,
9653 NK_TT_MAC_LANG_ARABIC =12, NK_TT_MAC_LANG_KOREAN =23,
9654 NK_TT_MAC_LANG_DUTCH =4 , NK_TT_MAC_LANG_RUSSIAN =32,
9655 NK_TT_MAC_LANG_FRENCH =1 , NK_TT_MAC_LANG_SPANISH =6 ,
9656 NK_TT_MAC_LANG_GERMAN =2 , NK_TT_MAC_LANG_SWEDISH =5 ,
9657 NK_TT_MAC_LANG_HEBREW =10, NK_TT_MAC_LANG_CHINESE_SIMPLIFIED =33,
9658 NK_TT_MAC_LANG_ITALIAN =3 , NK_TT_MAC_LANG_CHINESE_TRAD =19
9661 #define nk_ttBYTE(p) (* (const nk_byte *) (p))
9662 #define nk_ttCHAR(p) (* (const char *) (p))
9664 #if defined(NK_BIGENDIAN) && !defined(NK_ALLOW_UNALIGNED_TRUETYPE)
9665 #define nk_ttUSHORT(p) (* (nk_ushort *) (p))
9666 #define nk_ttSHORT(p) (* (nk_short *) (p))
9667 #define nk_ttULONG(p) (* (nk_uint *) (p))
9668 #define nk_ttLONG(p) (* (nk_int *) (p))
9670 static nk_ushort nk_ttUSHORT(
const nk_byte *p) {
return (nk_ushort)(p[0]*256 + p[1]); }
9671 static nk_short nk_ttSHORT(
const nk_byte *p) {
return (nk_short)(p[0]*256 + p[1]); }
9672 static nk_uint nk_ttULONG(
const nk_byte *p) {
return (nk_uint)((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]); }
9675 #define nk_tt_tag4(p,c0,c1,c2,c3)\
9676 ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
9677 #define nk_tt_tag(p,str) nk_tt_tag4(p,str[0],str[1],str[2],str[3])
9680 int glyph_index,
struct nk_tt_vertex **pvertices);
9683 nk_tt__find_table(
const nk_byte *data, nk_uint fontstart,
const char *tag)
9686 nk_int num_tables = nk_ttUSHORT(data+fontstart+4);
9687 nk_uint tabledir = fontstart + 12;
9689 for (i = 0; i < num_tables; ++i) {
9690 nk_uint loc = tabledir + (
nk_uint)(16*i);
9691 if (nk_tt_tag(data+loc+0, tag))
9692 return nk_ttULONG(data+loc+8);
9698 nk_tt_InitFont(
struct nk_tt_fontinfo *info,
const unsigned char *data2,
int fontstart)
9702 const nk_byte *data = (
const nk_byte *) data2;
9705 info->fontstart = fontstart;
9707 cmap = nk_tt__find_table(data, (nk_uint)fontstart,
"cmap");
9708 info->loca = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"loca");
9709 info->head = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"head");
9710 info->glyf = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"glyf");
9711 info->hhea = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"hhea");
9712 info->hmtx = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"hmtx");
9713 info->kern = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"kern");
9714 if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx)
9717 t = nk_tt__find_table(data, (nk_uint)fontstart,
"maxp");
9718 if (t) info->numGlyphs = nk_ttUSHORT(data+t+4);
9719 else info->numGlyphs = 0xffff;
9724 numTables = nk_ttUSHORT(data + cmap + 2);
9725 info->index_map = 0;
9726 for (i=0; i < numTables; ++i)
9728 nk_uint encoding_record = cmap + 4 + 8 * (
nk_uint)i;
9730 switch(nk_ttUSHORT(data+encoding_record)) {
9731 case NK_TT_PLATFORM_ID_MICROSOFT:
9732 switch (nk_ttUSHORT(data+encoding_record+2)) {
9733 case NK_TT_MS_EID_UNICODE_BMP:
9734 case NK_TT_MS_EID_UNICODE_FULL:
9736 info->index_map = (
int)(cmap + nk_ttULONG(data+encoding_record+4));
9740 case NK_TT_PLATFORM_ID_UNICODE:
9743 info->index_map = (
int)(cmap + nk_ttULONG(data+encoding_record+4));
9748 if (info->index_map == 0)
9750 info->indexToLocFormat = nk_ttUSHORT(data+info->head + 50);
9755 nk_tt_FindGlyphIndex(
const struct nk_tt_fontinfo *info,
int unicode_codepoint)
9757 const nk_byte *data = info->data;
9758 nk_uint index_map = (
nk_uint)info->index_map;
9760 nk_ushort format = nk_ttUSHORT(data + index_map + 0);
9762 nk_int bytes = nk_ttUSHORT(data + index_map + 2);
9763 if (unicode_codepoint < bytes-6)
9764 return nk_ttBYTE(data + index_map + 6 + unicode_codepoint);
9766 }
else if (format == 6) {
9767 nk_uint first = nk_ttUSHORT(data + index_map + 6);
9768 nk_uint count = nk_ttUSHORT(data + index_map + 8);
9769 if ((nk_uint) unicode_codepoint >= first && (nk_uint) unicode_codepoint < first+count)
9770 return nk_ttUSHORT(data + index_map + 10 + (unicode_codepoint - (
int)first)*2);
9772 }
else if (format == 2) {
9775 }
else if (format == 4) {
9776 nk_ushort segcount = nk_ttUSHORT(data+index_map+6) >> 1;
9777 nk_ushort searchRange = nk_ttUSHORT(data+index_map+8) >> 1;
9778 nk_ushort entrySelector = nk_ttUSHORT(data+index_map+10);
9779 nk_ushort rangeShift = nk_ttUSHORT(data+index_map+12) >> 1;
9782 nk_uint endCount = index_map + 14;
9783 nk_uint search = endCount;
9785 if (unicode_codepoint > 0xffff)
9790 if (unicode_codepoint >= nk_ttUSHORT(data + search + rangeShift*2))
9791 search += (
nk_uint)(rangeShift*2);
9795 while (entrySelector) {
9798 end = nk_ttUSHORT(data + search + searchRange*2);
9799 if (unicode_codepoint > end)
9800 search += (
nk_uint)(searchRange*2);
9806 nk_ushort offset, start;
9809 NK_ASSERT(unicode_codepoint <= nk_ttUSHORT(data + endCount + 2*item));
9810 start = nk_ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
9811 if (unicode_codepoint < start)
9814 offset = nk_ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
9816 return (nk_ushort) (unicode_codepoint + nk_ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
9818 return nk_ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
9820 }
else if (format == 12 || format == 13) {
9821 nk_uint ngroups = nk_ttULONG(data+index_map+12);
9823 low = 0; high = (
nk_int)ngroups;
9825 while (low < high) {
9826 nk_int mid = low + ((high-low) >> 1);
9827 nk_uint start_char = nk_ttULONG(data+index_map+16+mid*12);
9828 nk_uint end_char = nk_ttULONG(data+index_map+16+mid*12+4);
9829 if ((nk_uint) unicode_codepoint < start_char)
9831 else if ((nk_uint) unicode_codepoint > end_char)
9834 nk_uint start_glyph = nk_ttULONG(data+index_map+16+mid*12+8);
9836 return (
int)start_glyph + (
int)unicode_codepoint - (
int)start_char;
9838 return (
int)start_glyph;
9849 nk_tt_setvertex(struct nk_tt_vertex *v, nk_byte type, nk_int x, nk_int y, nk_int cx, nk_int cy)
9859 nk_tt__GetGlyfOffset(
const struct nk_tt_fontinfo *info,
int glyph_index)
9862 if (glyph_index >= info->numGlyphs)
return -1;
9863 if (info->indexToLocFormat >= 2)
return -1;
9865 if (info->indexToLocFormat == 0) {
9866 g1 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
9867 g2 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
9869 g1 = info->glyf + (
int)nk_ttULONG (info->data + info->loca + glyph_index * 4);
9870 g2 = info->glyf + (
int)nk_ttULONG (info->data + info->loca + glyph_index * 4 + 4);
9872 return g1==g2 ? -1 : g1;
9876 nk_tt_GetGlyphBox(
const struct nk_tt_fontinfo *info,
int glyph_index,
9877 int *x0,
int *y0,
int *x1,
int *y1)
9879 int g = nk_tt__GetGlyfOffset(info, glyph_index);
9880 if (g < 0)
return 0;
9882 if (x0) *x0 = nk_ttSHORT(info->data + g + 2);
9883 if (y0) *y0 = nk_ttSHORT(info->data + g + 4);
9884 if (x1) *x1 = nk_ttSHORT(info->data + g + 6);
9885 if (y1) *y1 = nk_ttSHORT(info->data + g + 8);
9890 stbtt__close_shape(
struct nk_tt_vertex *vertices,
int num_vertices,
int was_off,
9891 int start_off, nk_int sx, nk_int sy, nk_int scx, nk_int scy, nk_int cx, nk_int cy)
9895 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
9896 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, sx,sy,scx,scy);
9899 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve,sx,sy,cx,cy);
9901 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline,sx,sy,0,0);
9903 return num_vertices;
9907 nk_tt_GetGlyphShape(
const struct nk_tt_fontinfo *info,
struct nk_allocator *alloc,
9908 int glyph_index,
struct nk_tt_vertex **pvertices)
9910 nk_short numberOfContours;
9911 const nk_byte *endPtsOfContours;
9912 const nk_byte *data = info->data;
9913 struct nk_tt_vertex *vertices=0;
9915 int g = nk_tt__GetGlyfOffset(info, glyph_index);
9918 if (g < 0)
return 0;
9919 numberOfContours = nk_ttSHORT(data + g);
9920 if (numberOfContours > 0) {
9921 nk_byte flags=0,flagcount;
9922 nk_int ins, i,j=0,
m,n, next_move, was_off=0, off, start_off=0;
9923 nk_int x,y,cx,cy,sx,sy, scx,scy;
9924 const nk_byte *points;
9925 endPtsOfContours = (data + g + 10);
9926 ins = nk_ttUSHORT(data + g + 10 + numberOfContours * 2);
9927 points = data + g + 10 + numberOfContours * 2 + 2 + ins;
9929 n = 1+nk_ttUSHORT(endPtsOfContours + numberOfContours*2-2);
9930 m = n + 2*numberOfContours;
9931 vertices = (
struct nk_tt_vertex *)alloc->
alloc(alloc->
userdata, 0, (nk_size)m *
sizeof(vertices[0]));
9944 for (i=0; i < n; ++i) {
9945 if (flagcount == 0) {
9948 flagcount = *points++;
9950 vertices[off+i].type = flags;
9955 for (i=0; i < n; ++i) {
9956 flags = vertices[off+i].type;
9958 nk_short dx = *points++;
9959 x += (flags & 16) ? dx : -dx;
9961 if (!(flags & 16)) {
9962 x = x + (
nk_short) (points[0]*256 + points[1]);
9971 for (i=0; i < n; ++i) {
9972 flags = vertices[off+i].type;
9974 nk_short dy = *points++;
9975 y += (flags & 32) ? dy : -dy;
9977 if (!(flags & 32)) {
9978 y = y + (
nk_short) (points[0]*256 + points[1]);
9987 sx = sy = cx = cy = scx = scy = 0;
9988 for (i=0; i < n; ++i)
9990 flags = vertices[off+i].type;
9994 if (next_move == i) {
9996 num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
9999 start_off = !(flags & 1);
10005 if (!(vertices[off+i+1].type & 1)) {
10007 sx = (x + (
nk_int) vertices[off+i+1].x) >> 1;
10008 sy = (y + (
nk_int) vertices[off+i+1].y) >> 1;
10011 sx = (
nk_int) vertices[off+i+1].x;
10012 sy = (
nk_int) vertices[off+i+1].y;
10019 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vmove,sx,sy,0,0);
10021 next_move = 1 + nk_ttUSHORT(endPtsOfContours+j*2);
10027 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
10033 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, x,y, cx, cy);
10034 else nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline, x,y,0,0);
10039 num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
10040 }
else if (numberOfContours == -1) {
10043 const nk_byte *comp = data + g + 10;
10049 nk_ushort flags, gidx;
10050 int comp_num_verts = 0, i;
10051 struct nk_tt_vertex *comp_verts = 0, *tmp = 0;
10052 float mtx[6] = {1,0,0,1,0,0},
m, n;
10054 flags = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
10055 gidx = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
10059 mtx[4] = nk_ttSHORT(comp); comp+=2;
10060 mtx[5] = nk_ttSHORT(comp); comp+=2;
10062 mtx[4] = nk_ttCHAR(comp); comp+=1;
10063 mtx[5] = nk_ttCHAR(comp); comp+=1;
10069 if (flags & (1<<3)) {
10070 mtx[0] = mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
10071 mtx[1] = mtx[2] = 0;
10072 }
else if (flags & (1<<6)) {
10073 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
10074 mtx[1] = mtx[2] = 0;
10075 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
10076 }
else if (flags & (1<<7)) {
10077 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
10078 mtx[1] = nk_ttSHORT(comp)/16384.0f; comp+=2;
10079 mtx[2] = nk_ttSHORT(comp)/16384.0f; comp+=2;
10080 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
10084 m = (float) NK_SQRT(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
10085 n = (float) NK_SQRT(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
10088 comp_num_verts = nk_tt_GetGlyphShape(info, alloc, gidx, &comp_verts);
10089 if (comp_num_verts > 0)
10092 for (i = 0; i < comp_num_verts; ++i) {
10093 struct nk_tt_vertex* v = &comp_verts[i];
10096 v->x = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
10097 v->y = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
10099 v->cx = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
10100 v->cy = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
10103 tmp = (
struct nk_tt_vertex*)alloc->
alloc(alloc->
userdata, 0,
10104 (nk_size)(num_vertices+comp_num_verts)*
sizeof(
struct nk_tt_vertex));
10107 if (comp_verts) alloc->
free(alloc->
userdata, comp_verts);
10110 if (num_vertices > 0) NK_MEMCPY(tmp, vertices, (nk_size)num_vertices*
sizeof(
struct nk_tt_vertex));
10111 NK_MEMCPY(tmp+num_vertices, comp_verts, (nk_size)comp_num_verts*
sizeof(
struct nk_tt_vertex));
10115 num_vertices += comp_num_verts;
10118 more = flags & (1<<5);
10120 }
else if (numberOfContours < 0) {
10126 *pvertices = vertices;
10127 return num_vertices;
10131 nk_tt_GetGlyphHMetrics(
const struct nk_tt_fontinfo *info,
int glyph_index,
10132 int *advanceWidth,
int *leftSideBearing)
10134 nk_ushort numOfLongHorMetrics = nk_ttUSHORT(info->data+info->hhea + 34);
10135 if (glyph_index < numOfLongHorMetrics) {
10137 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index);
10138 if (leftSideBearing)
10139 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
10142 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
10143 if (leftSideBearing)
10144 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
10149 nk_tt_GetFontVMetrics(
const struct nk_tt_fontinfo *info,
10150 int *ascent,
int *descent,
int *lineGap)
10152 if (ascent ) *ascent = nk_ttSHORT(info->data+info->hhea + 4);
10153 if (descent) *descent = nk_ttSHORT(info->data+info->hhea + 6);
10154 if (lineGap) *lineGap = nk_ttSHORT(info->data+info->hhea + 8);
10158 nk_tt_ScaleForPixelHeight(
const struct nk_tt_fontinfo *info,
float height)
10160 int fheight = nk_ttSHORT(info->data + info->hhea + 4) - nk_ttSHORT(info->data + info->hhea + 6);
10161 return (
float) height / (float)fheight;
10165 nk_tt_ScaleForMappingEmToPixels(
const struct nk_tt_fontinfo *info,
float pixels)
10167 int unitsPerEm = nk_ttUSHORT(info->data + info->head + 18);
10168 return pixels / (float)unitsPerEm;
10175 nk_tt_GetGlyphBitmapBoxSubpixel(
const struct nk_tt_fontinfo *font,
10176 int glyph,
float scale_x,
float scale_y,
float shift_x,
float shift_y,
10177 int *ix0,
int *iy0,
int *ix1,
int *iy1)
10180 if (!nk_tt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
10188 if (ix0) *ix0 = nk_ifloorf((
float)x0 * scale_x + shift_x);
10189 if (iy0) *iy0 = nk_ifloorf((
float)-y1 * scale_y + shift_y);
10190 if (ix1) *ix1 = nk_iceilf ((
float)x1 * scale_x + shift_x);
10191 if (iy1) *iy1 = nk_iceilf ((
float)-y0 * scale_y + shift_y);
10196 nk_tt_GetGlyphBitmapBox(
const struct nk_tt_fontinfo *font,
int glyph,
10197 float scale_x,
float scale_y,
int *ix0,
int *iy0,
int *ix1,
int *iy1)
10199 nk_tt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
10206 nk_tt__hheap_alloc(
struct nk_tt__hheap *hh, nk_size size)
10208 if (hh->first_free) {
10209 void *p = hh->first_free;
10210 hh->first_free = * (
void **) p;
10213 if (hh->num_remaining_in_head_chunk == 0) {
10214 int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
10215 struct nk_tt__hheap_chunk *c = (
struct nk_tt__hheap_chunk *)
10216 hh->alloc.alloc(hh->alloc.userdata, 0,
10217 sizeof(
struct nk_tt__hheap_chunk) + size * (nk_size)count);
10218 if (c == 0)
return 0;
10219 c->next = hh->head;
10221 hh->num_remaining_in_head_chunk = count;
10223 --hh->num_remaining_in_head_chunk;
10224 return (
char *) (hh->head) + size * (nk_size)hh->num_remaining_in_head_chunk;
10229 nk_tt__hheap_free(
struct nk_tt__hheap *hh,
void *p)
10231 *(
void **) p = hh->first_free;
10232 hh->first_free = p;
10236 nk_tt__hheap_cleanup(
struct nk_tt__hheap *hh)
10238 struct nk_tt__hheap_chunk *c = hh->head;
10240 struct nk_tt__hheap_chunk *n = c->next;
10241 hh->alloc.free(hh->alloc.userdata, c);
10247 nk_tt__new_active(
struct nk_tt__hheap *hh,
struct nk_tt__edge *e,
10248 int off_x,
float start_point)
10250 struct nk_tt__active_edge *z = (
struct nk_tt__active_edge *)
10251 nk_tt__hheap_alloc(hh,
sizeof(*z));
10252 float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
10256 z->fdy = (dxdy != 0) ? (1/dxdy): 0;
10257 z->fx = e->x0 + dxdy * (start_point - e->y0);
10258 z->fx -= (float)off_x;
10259 z->direction = e->invert ? 1.0f : -1.0f;
10267 nk_tt__handle_clipped_edge(
float *scanline,
int x,
struct nk_tt__active_edge *e,
10268 float x0,
float y0,
float x1,
float y1)
10270 if (y0 == y1)
return;
10271 NK_ASSERT(y0 < y1);
10272 NK_ASSERT(e->sy <= e->ey);
10273 if (y0 > e->ey)
return;
10274 if (y1 < e->sy)
return;
10276 x0 += (x1-x0) * (e->sy - y0) / (y1-y0);
10280 x1 += (x1-x0) * (e->ey - y1) / (y1-y0);
10284 if (x0 == x) NK_ASSERT(x1 <= x+1);
10285 else if (x0 == x+1) NK_ASSERT(x1 >= x);
10286 else if (x0 <= x) NK_ASSERT(x1 <= x);
10287 else if (x0 >= x+1) NK_ASSERT(x1 >= x+1);
10288 else NK_ASSERT(x1 >= x && x1 <= x+1);
10290 if (x0 <= x && x1 <= x)
10291 scanline[x] += e->direction * (y1-y0);
10292 else if (x0 >= x+1 && x1 >= x+1);
10294 NK_ASSERT(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1);
10296 scanline[x] += (float)e->direction * (
float)(y1-y0) * (1.0f-((x0-(
float)x)+(x1-(float)x))/2.0f);
10301 nk_tt__fill_active_edges_new(
float *scanline,
float *scanline_fill,
int len,
10302 struct nk_tt__active_edge *e,
float y_top)
10304 float y_bottom = y_top+1;
10309 NK_ASSERT(e->ey >= y_top);
10314 nk_tt__handle_clipped_edge(scanline,(
int) x0,e, x0,y_top, x0,y_bottom);
10315 nk_tt__handle_clipped_edge(scanline_fill-1,(
int) x0+1,e, x0,y_top, x0,y_bottom);
10317 nk_tt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
10323 float xb = x0 + dx;
10324 float x_top, x_bottom;
10327 NK_ASSERT(e->sy <= y_bottom && e->ey >= y_top);
10332 if (e->sy > y_top) {
10333 x_top = x0 + dx * (e->sy - y_top);
10340 if (e->ey < y_bottom) {
10341 x_bottom = x0 + dx * (e->ey - y_top);
10348 if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len)
10351 if ((
int) x_top == (
int) x_bottom) {
10354 int x = (
int) x_top;
10356 NK_ASSERT(x >= 0 && x < len);
10357 scanline[x] += e->direction * (1.0f-(((float)x_top - (
float)x) + ((
float)x_bottom-(float)x))/2.0f) * (float)height;
10358 scanline_fill[x] += e->direction * (float)height;
10361 float y_crossing, step, sign, area;
10363 if (x_top > x_bottom)
10367 y0 = y_bottom - (y0 - y_top);
10368 y1 = y_bottom - (y1 - y_top);
10369 t = y0; y0 = y1; y1 = t;
10370 t = x_bottom; x_bottom = x_top; x_top = t;
10373 t = x0; x0 = xb; xb = t;
10377 x2 = (
int) x_bottom;
10379 y_crossing = ((float)x1+1 - (
float)x0) * (
float)dy + (float)y_top;
10381 sign = e->direction;
10383 area = sign * (y_crossing-y0);
10385 scanline[x1] += area * (1.0f-((float)((
float)x_top - (float)x1)+(float)(x1+1-x1))/2.0f);
10388 for (x = x1+1; x < x2; ++x) {
10389 scanline[x] += area + step/2;
10392 y_crossing += (float)dy * (
float)(x2 - (x1+1));
10394 scanline[x2] += area + sign * (1.0f-((float)(x2-x2)+((float)x_bottom-(
float)x2))/2.0f) * (y1-y_crossing);
10395 scanline_fill[x2] += sign * (y1-y0);
10405 for (x=0; x < len; ++x)
10422 float x1 = (float) (x);
10423 float x2 = (float) (x+1);
10425 float y3 = y_bottom;
10428 yb = ((float)x - x0) / dx + y_top;
10429 y2 = ((float)x+1 - x0) / dx + y_top;
10431 if (x0 < x1 && x3 > x2) {
10432 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10433 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x2,y2);
10434 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10435 }
else if (x3 < x1 && x0 > x2) {
10436 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10437 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x1,yb);
10438 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10439 }
else if (x0 < x1 && x3 > x1) {
10440 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10441 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10442 }
else if (x3 < x1 && x0 > x1) {
10443 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10444 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10445 }
else if (x0 < x2 && x3 > x2) {
10446 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10447 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10448 }
else if (x3 < x2 && x0 > x2) {
10449 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10450 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10452 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x3,y3);
10463 nk_tt__rasterize_sorted_edges(
struct nk_tt__bitmap *result,
struct nk_tt__edge *e,
10464 int n,
int vsubsample,
int off_x,
int off_y,
struct nk_allocator *alloc)
10466 struct nk_tt__hheap hh;
10467 struct nk_tt__active_edge *active = 0;
10469 float scanline_data[129], *scanline, *scanline2;
10475 if (result->w > 64)
10476 scanline = (
float *) alloc->
alloc(alloc->
userdata,0, (nk_size)(result->w*2+1) *
sizeof(
float));
10477 else scanline = scanline_data;
10479 scanline2 = scanline + result->w;
10481 e[n].y0 = (float) (off_y + result->h) + 1;
10483 while (j < result->h)
10486 float scan_y_top = (float)y + 0.0f;
10487 float scan_y_bottom = (float)y + 1.0f;
10488 struct nk_tt__active_edge **step = &active;
10490 NK_MEMSET(scanline , 0, (nk_size)result->w*
sizeof(scanline[0]));
10491 NK_MEMSET(scanline2, 0, (nk_size)(result->w+1)*
sizeof(scanline[0]));
10496 struct nk_tt__active_edge * z = *step;
10497 if (z->ey <= scan_y_top) {
10499 NK_ASSERT(z->direction);
10501 nk_tt__hheap_free(&hh, z);
10503 step = &((*step)->next);
10508 while (e->y0 <= scan_y_bottom) {
10509 if (e->y0 != e->y1) {
10510 struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top);
10512 NK_ASSERT(z->ey >= scan_y_top);
10523 nk_tt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
10527 for (i=0; i < result->w; ++i) {
10530 sum += scanline2[i];
10531 k = scanline[i] + sum;
10532 k = (float)
NK_ABS(k) * 255.0f + 0.5f;
10534 if (m > 255) m = 255;
10535 result->pixels[j*result->stride + i] = (
unsigned char) m;
10541 struct nk_tt__active_edge *z = *step;
10543 step = &((*step)->next);
10548 nk_tt__hheap_cleanup(&hh);
10549 if (scanline != scanline_data)
10553 #define NK_TT__COMPARE(a,b) ((a)->y0 < (b)->y0)
10555 nk_tt__sort_edges_ins_sort(
struct nk_tt__edge *p,
int n)
10558 for (i=1; i < n; ++i) {
10559 struct nk_tt__edge t = p[i], *a = &t;
10562 struct nk_tt__edge *b = &p[j-1];
10563 int c = NK_TT__COMPARE(a,b);
10574 nk_tt__sort_edges_quicksort(
struct nk_tt__edge *p,
int n)
10578 struct nk_tt__edge t;
10579 int c01,c12,c,
m,i,j;
10583 c01 = NK_TT__COMPARE(&p[0],&p[m]);
10584 c12 = NK_TT__COMPARE(&p[m],&p[n-1]);
10590 c = NK_TT__COMPARE(&p[0],&p[n-1]);
10593 z = (c == c12) ? 0 : n-1;
10612 if (!NK_TT__COMPARE(&p[i], &p[0]))
break;
10615 if (!NK_TT__COMPARE(&p[0], &p[j]))
break;
10631 nk_tt__sort_edges_quicksort(p,j);
10635 nk_tt__sort_edges_quicksort(p+i, n-i);
10642 nk_tt__sort_edges(
struct nk_tt__edge *p,
int n)
10644 nk_tt__sort_edges_quicksort(p, n);
10645 nk_tt__sort_edges_ins_sort(p, n);
10649 nk_tt__rasterize(
struct nk_tt__bitmap *result,
struct nk_tt__point *pts,
10650 int *wcount,
int windings,
float scale_x,
float scale_y,
10651 float shift_x,
float shift_y,
int off_x,
int off_y,
int invert,
10654 float y_scale_inv = invert ? -scale_y : scale_y;
10655 struct nk_tt__edge *e;
10657 int vsubsample = 1;
10662 for (i=0; i < windings; ++i)
10665 e = (
struct nk_tt__edge*)
10666 alloc->
alloc(alloc->
userdata, 0,(
sizeof(*e) * (nk_size)(n+1)));
10667 if (e == 0)
return;
10671 for (i=0; i < windings; ++i)
10673 struct nk_tt__point *p = pts +
m;
10676 for (k=0; k < wcount[i]; j=k++) {
10679 if (p[j].y == p[k].y)
10684 if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
10688 e[n].x0 = p[a].x * scale_x + shift_x;
10689 e[n].y0 = (p[a].y * y_scale_inv + shift_y) * (
float)vsubsample;
10690 e[n].x1 = p[b].x * scale_x + shift_x;
10691 e[n].y1 = (p[b].y * y_scale_inv + shift_y) * (
float)vsubsample;
10698 nk_tt__sort_edges(e, n);
10700 nk_tt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, alloc);
10705 nk_tt__add_point(
struct nk_tt__point *points,
int n,
float x,
float y)
10707 if (!points)
return;
10713 nk_tt__tesselate_curve(
struct nk_tt__point *points,
int *num_points,
10714 float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
10715 float objspace_flatness_squared,
int n)
10720 float mx = (x0 + 2*x1 + x2)/4;
10721 float my = (y0 + 2*y1 + y2)/4;
10723 float dx = (x0+x2)/2 - mx;
10724 float dy = (y0+y2)/2 - my;
10729 if (dx*dx+dy*dy > objspace_flatness_squared) {
10730 nk_tt__tesselate_curve(points, num_points, x0,y0,
10731 (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
10732 nk_tt__tesselate_curve(points, num_points, mx,my,
10733 (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
10735 nk_tt__add_point(points, *num_points,x2,y2);
10736 *num_points = *num_points+1;
10743 nk_tt_FlattenCurves(
struct nk_tt_vertex *vertices,
int num_verts,
10744 float objspace_flatness,
int **contour_lengths,
int *num_contours,
10747 struct nk_tt__point *points=0;
10749 float objspace_flatness_squared = objspace_flatness * objspace_flatness;
10756 for (i=0; i < num_verts; ++i)
10757 if (vertices[i].type == NK_TT_vmove) ++n;
10760 if (n == 0)
return 0;
10762 *contour_lengths = (
int *)
10763 alloc->
alloc(alloc->
userdata,0, (
sizeof(**contour_lengths) * (nk_size)n));
10764 if (*contour_lengths == 0) {
10770 for (pass=0; pass < 2; ++pass)
10774 points = (
struct nk_tt__point *)
10775 alloc->
alloc(alloc->
userdata,0, (nk_size)num_points *
sizeof(points[0]));
10776 if (points == 0)
goto error;
10781 for (i=0; i < num_verts; ++i)
10783 switch (vertices[i].type) {
10787 (*contour_lengths)[n] = num_points - start;
10789 start = num_points;
10791 x = vertices[i].x, y = vertices[i].y;
10792 nk_tt__add_point(points, num_points++, x,y);
10795 x = vertices[i].x, y = vertices[i].y;
10796 nk_tt__add_point(points, num_points++, x, y);
10799 nk_tt__tesselate_curve(points, &num_points, x,y,
10800 vertices[i].cx, vertices[i].cy,
10801 vertices[i].x, vertices[i].y,
10802 objspace_flatness_squared, 0);
10803 x = vertices[i].x, y = vertices[i].y;
10808 (*contour_lengths)[n] = num_points - start;
10815 *contour_lengths = 0;
10821 nk_tt_Rasterize(
struct nk_tt__bitmap *result,
float flatness_in_pixels,
10822 struct nk_tt_vertex *vertices,
int num_verts,
10823 float scale_x,
float scale_y,
float shift_x,
float shift_y,
10824 int x_off,
int y_off,
int invert,
struct nk_allocator *alloc)
10826 float scale = scale_x > scale_y ? scale_y : scale_x;
10827 int winding_count, *winding_lengths;
10828 struct nk_tt__point *windings = nk_tt_FlattenCurves(vertices, num_verts,
10829 flatness_in_pixels / scale, &winding_lengths, &winding_count, alloc);
10833 nk_tt__rasterize(result, windings, winding_lengths, winding_count,
10834 scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, alloc);
10841 nk_tt_MakeGlyphBitmapSubpixel(
const struct nk_tt_fontinfo *info,
unsigned char *output,
10842 int out_w,
int out_h,
int out_stride,
float scale_x,
float scale_y,
10843 float shift_x,
float shift_y,
int glyph,
struct nk_allocator *alloc)
10846 struct nk_tt_vertex *vertices;
10847 int num_verts = nk_tt_GetGlyphShape(info, alloc, glyph, &vertices);
10848 struct nk_tt__bitmap gbm;
10850 nk_tt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x,
10851 shift_y, &ix0,&iy0,0,0);
10855 gbm.stride = out_stride;
10857 if (gbm.w && gbm.h)
10858 nk_tt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y,
10859 shift_x, shift_y, ix0,iy0, 1, alloc);
10867 nk_tt_PackBegin(
struct nk_tt_pack_context *spc,
unsigned char *pixels,
10868 int pw,
int ph,
int stride_in_bytes,
int padding,
struct nk_allocator *alloc)
10870 int num_nodes = pw - padding;
10871 struct nk_rp_context *context = (
struct nk_rp_context *)
10873 struct nk_rp_node *nodes = (
struct nk_rp_node*)
10874 alloc->
alloc(alloc->
userdata,0, (
sizeof(*nodes ) * (nk_size)num_nodes));
10876 if (context == 0 || nodes == 0) {
10877 if (context != 0) alloc->
free(alloc->
userdata, context);
10884 spc->pixels = pixels;
10885 spc->pack_info = context;
10886 spc->nodes = nodes;
10887 spc->padding = padding;
10888 spc->stride_in_bytes = (stride_in_bytes != 0) ? stride_in_bytes : pw;
10889 spc->h_oversample = 1;
10890 spc->v_oversample = 1;
10892 nk_rp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
10894 NK_MEMSET(pixels, 0, (nk_size)(pw*ph));
10899 nk_tt_PackEnd(
struct nk_tt_pack_context *spc,
struct nk_allocator *alloc)
10906 nk_tt_PackSetOversampling(
struct nk_tt_pack_context *spc,
10907 unsigned int h_oversample,
unsigned int v_oversample)
10909 NK_ASSERT(h_oversample <= NK_TT_MAX_OVERSAMPLE);
10910 NK_ASSERT(v_oversample <= NK_TT_MAX_OVERSAMPLE);
10911 if (h_oversample <= NK_TT_MAX_OVERSAMPLE)
10912 spc->h_oversample = h_oversample;
10913 if (v_oversample <= NK_TT_MAX_OVERSAMPLE)
10914 spc->v_oversample = v_oversample;
10918 nk_tt__h_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
10921 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
10922 int safe_w = w - kernel_width;
10925 for (j=0; j < h; ++j)
10928 unsigned int total;
10929 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
10934 switch (kernel_width) {
10936 for (i=0; i <= safe_w; ++i) {
10937 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10938 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10939 pixels[i] = (
unsigned char) (total / 2);
10943 for (i=0; i <= safe_w; ++i) {
10944 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10945 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10946 pixels[i] = (
unsigned char) (total / 3);
10950 for (i=0; i <= safe_w; ++i) {
10951 total += (
unsigned int)pixels[i] - buffer[i & NK_TT__OVER_MASK];
10952 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10953 pixels[i] = (
unsigned char) (total / 4);
10957 for (i=0; i <= safe_w; ++i) {
10958 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10959 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10960 pixels[i] = (
unsigned char) (total / 5);
10964 for (i=0; i <= safe_w; ++i) {
10965 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10966 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10967 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
10972 for (; i < w; ++i) {
10973 NK_ASSERT(pixels[i] == 0);
10974 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
10975 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
10977 pixels += stride_in_bytes;
10982 nk_tt__v_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
10985 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
10986 int safe_h = h - kernel_width;
10989 for (j=0; j < w; ++j)
10992 unsigned int total;
10993 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
10998 switch (kernel_width) {
11000 for (i=0; i <= safe_h; ++i) {
11001 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
11002 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
11003 pixels[i*stride_in_bytes] = (
unsigned char) (total / 2);
11007 for (i=0; i <= safe_h; ++i) {
11008 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
11009 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
11010 pixels[i*stride_in_bytes] = (
unsigned char) (total / 3);
11014 for (i=0; i <= safe_h; ++i) {
11015 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
11016 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
11017 pixels[i*stride_in_bytes] = (
unsigned char) (total / 4);
11021 for (i=0; i <= safe_h; ++i) {
11022 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
11023 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
11024 pixels[i*stride_in_bytes] = (
unsigned char) (total / 5);
11028 for (i=0; i <= safe_h; ++i) {
11029 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
11030 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
11031 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
11036 for (; i < h; ++i) {
11037 NK_ASSERT(pixels[i*stride_in_bytes] == 0);
11038 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
11039 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
11046 nk_tt__oversample_shift(
int oversample)
11055 return (
float)-(oversample - 1) / (2.0f * (
float)oversample);
11060 nk_tt_PackFontRangesGatherRects(
struct nk_tt_pack_context *spc,
11061 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
11062 int num_ranges,
struct nk_rp_rect *rects)
11067 for (i=0; i < num_ranges; ++i) {
11068 float fh = ranges[i].font_size;
11069 float scale = (fh > 0) ? nk_tt_ScaleForPixelHeight(info, fh):
11070 nk_tt_ScaleForMappingEmToPixels(info, -fh);
11071 ranges[i].h_oversample = (
unsigned char) spc->h_oversample;
11072 ranges[i].v_oversample = (
unsigned char) spc->v_oversample;
11073 for (j=0; j < ranges[i].num_chars; ++j) {
11075 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
11076 ranges[i].first_unicode_codepoint_in_range + j :
11077 ranges[i].array_of_unicode_codepoints[j];
11079 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
11080 nk_tt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * (
float)spc->h_oversample,
11081 scale * (
float)spc->v_oversample, 0,0, &x0,&y0,&x1,&y1);
11082 rects[k].w = (nk_rp_coord) (x1-x0 + spc->padding + (
int)spc->h_oversample-1);
11083 rects[k].h = (nk_rp_coord) (y1-y0 + spc->padding + (
int)spc->v_oversample-1);
11091 nk_tt_PackFontRangesRenderIntoRects(
struct nk_tt_pack_context *spc,
11092 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
11093 int num_ranges,
struct nk_rp_rect *rects,
struct nk_allocator *alloc)
11095 int i,j,k, return_value = 1;
11097 int old_h_over = (
int)spc->h_oversample;
11098 int old_v_over = (
int)spc->v_oversample;
11102 for (i=0; i < num_ranges; ++i)
11104 float fh = ranges[i].font_size;
11105 float recip_h,recip_v,sub_x,sub_y;
11106 float scale = fh > 0 ? nk_tt_ScaleForPixelHeight(info, fh):
11107 nk_tt_ScaleForMappingEmToPixels(info, -fh);
11109 spc->h_oversample = ranges[i].h_oversample;
11110 spc->v_oversample = ranges[i].v_oversample;
11112 recip_h = 1.0f / (float)spc->h_oversample;
11113 recip_v = 1.0f / (
float)spc->v_oversample;
11115 sub_x = nk_tt__oversample_shift((
int)spc->h_oversample);
11116 sub_y = nk_tt__oversample_shift((
int)spc->v_oversample);
11118 for (j=0; j < ranges[i].num_chars; ++j)
11120 struct nk_rp_rect *r = &rects[k];
11123 struct nk_tt_packedchar *bc = &ranges[i].chardata_for_range[j];
11124 int advance, lsb, x0,y0,x1,y1;
11125 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
11126 ranges[i].first_unicode_codepoint_in_range + j :
11127 ranges[i].array_of_unicode_codepoints[j];
11128 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
11129 nk_rp_coord pad = (nk_rp_coord) spc->padding;
11132 r->x = (nk_rp_coord)((
int)r->x + (
int)pad);
11133 r->y = (nk_rp_coord)((
int)r->y + (
int)pad);
11134 r->w = (nk_rp_coord)((
int)r->w - (
int)pad);
11135 r->h = (nk_rp_coord)((
int)r->h - (
int)pad);
11137 nk_tt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
11138 nk_tt_GetGlyphBitmapBox(info, glyph, scale * (
float)spc->h_oversample,
11139 (scale * (
float)spc->v_oversample), &x0,&y0,&x1,&y1);
11140 nk_tt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes,
11141 (
int)(r->w - spc->h_oversample+1), (
int)(r->h - spc->v_oversample+1),
11142 spc->stride_in_bytes, scale * (
float)spc->h_oversample,
11143 scale * (
float)spc->v_oversample, 0,0, glyph, alloc);
11145 if (spc->h_oversample > 1)
11146 nk_tt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
11147 r->w, r->h, spc->stride_in_bytes, (
int)spc->h_oversample);
11149 if (spc->v_oversample > 1)
11150 nk_tt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
11151 r->w, r->h, spc->stride_in_bytes, (
int)spc->v_oversample);
11154 bc->y0 = (nk_ushort) r->y;
11157 bc->xadvance = scale * (float)advance;
11158 bc->xoff = (float) x0 * recip_h + sub_x;
11159 bc->yoff = (float) y0 * recip_v + sub_y;
11160 bc->xoff2 = ((float)x0 + r->w) * recip_h + sub_x;
11161 bc->yoff2 = ((float)y0 + r->h) * recip_v + sub_y;
11169 spc->h_oversample = (
unsigned int)old_h_over;
11170 spc->v_oversample = (
unsigned int)old_v_over;
11171 return return_value;
11175 nk_tt_GetPackedQuad(
struct nk_tt_packedchar *chardata,
int pw,
int ph,
11176 int char_index,
float *xpos,
float *ypos,
struct nk_tt_aligned_quad *q,
11177 int align_to_integer)
11179 float ipw = 1.0f / (float)pw, iph = 1.0f / (
float)ph;
11180 struct nk_tt_packedchar *b = (
struct nk_tt_packedchar*)(chardata + char_index);
11181 if (align_to_integer) {
11182 int tx = nk_ifloorf((*xpos + b->xoff) + 0.5f);
11183 int ty = nk_ifloorf((*ypos + b->yoff) + 0.5f);
11185 float x = (float)tx;
11186 float y = (float)ty;
11190 q->x1 = x + b->xoff2 - b->xoff;
11191 q->y1 = y + b->yoff2 - b->yoff;
11193 q->x0 = *xpos + b->xoff;
11194 q->y0 = *ypos + b->yoff;
11195 q->x1 = *xpos + b->xoff2;
11196 q->y1 = *ypos + b->yoff2;
11198 q->s0 = b->x0 * ipw;
11199 q->t0 = b->y0 * iph;
11200 q->s1 = b->x1 * ipw;
11201 q->t1 = b->y1 * iph;
11202 *xpos += b->xadvance;
11210 struct nk_font_bake_data {
11211 struct nk_tt_fontinfo info;
11212 struct nk_rp_rect *rects;
11213 struct nk_tt_pack_range *ranges;
11214 nk_rune range_count;
11217 struct nk_font_baker {
11219 struct nk_tt_pack_context spc;
11220 struct nk_font_bake_data *build;
11221 struct nk_tt_packedchar *packed_chars;
11222 struct nk_rp_rect *rects;
11223 struct nk_tt_pack_range *ranges;
11233 nk_range_count(
const nk_rune *range)
11235 const nk_rune *iter = range;
11237 if (!range)
return 0;
11238 while (*(iter++) != 0);
11239 return (iter == range) ? 0 : (
int)((iter - range)/2);
11243 nk_range_glyph_count(
const nk_rune *range,
int count)
11246 int total_glyphs = 0;
11247 for (i = 0; i < count; ++i) {
11249 nk_rune f = range[(i*2)+0];
11250 nk_rune t = range[(i*2)+1];
11252 diff = (
int)((t - f) + 1);
11253 total_glyphs += diff;
11255 return total_glyphs;
11259 nk_font_default_glyph_ranges(
void)
11261 NK_STORAGE const nk_rune ranges[] = {0x0020, 0x00FF, 0};
11266 nk_font_chinese_glyph_ranges(
void)
11280 nk_font_cyrillic_glyph_ranges(
void)
11293 nk_font_korean_glyph_ranges(
void)
11305 nk_font_baker_memory(nk_size *temp,
int *glyph_count,
11306 struct nk_font_config *config_list,
int count)
11308 int range_count = 0;
11309 int total_range_count = 0;
11310 struct nk_font_config *iter;
11312 NK_ASSERT(config_list);
11313 NK_ASSERT(glyph_count);
11314 if (!config_list) {
11321 if (!config_list->range)
11322 config_list->range = nk_font_default_glyph_ranges();
11323 for (iter = config_list; iter; iter = iter->next) {
11324 range_count = nk_range_count(iter->range);
11325 total_range_count += range_count;
11326 *glyph_count += nk_range_glyph_count(iter->range, range_count);
11329 *temp = (
nk_size)*glyph_count *
sizeof(
struct nk_rp_rect);
11330 *temp += (
nk_size)total_range_count *
sizeof(
struct nk_tt_pack_range);
11331 *temp += (
nk_size)*glyph_count *
sizeof(
struct nk_tt_packedchar);
11332 *temp += (
nk_size)count *
sizeof(
struct nk_font_bake_data);
11333 *temp +=
sizeof(
struct nk_font_baker);
11334 *temp += nk_rect_align + nk_range_align + nk_char_align;
11335 *temp += nk_build_align + nk_baker_align;
11339 nk_font_baker(
void *memory,
int glyph_count,
int count,
struct nk_allocator *alloc)
11341 struct nk_font_baker *baker;
11342 if (!memory)
return 0;
11344 baker = (
struct nk_font_baker*)
NK_ALIGN_PTR(memory, nk_baker_align);
11345 baker->build = (
struct nk_font_bake_data*)
NK_ALIGN_PTR((baker + 1), nk_build_align);
11346 baker->packed_chars = (
struct nk_tt_packedchar*)
NK_ALIGN_PTR((baker->build + count), nk_char_align);
11347 baker->rects = (
struct nk_rp_rect*)
NK_ALIGN_PTR((baker->packed_chars + glyph_count), nk_rect_align);
11348 baker->ranges = (
struct nk_tt_pack_range*)
NK_ALIGN_PTR((baker->rects + glyph_count), nk_range_align);
11349 baker->alloc = *alloc;
11354 nk_font_bake_pack(
struct nk_font_baker *baker,
11355 nk_size *image_memory,
int *width,
int *height,
struct nk_recti *custom,
11356 const struct nk_font_config *config_list,
int count,
11359 NK_STORAGE const nk_size max_height = 1024 * 32;
11360 const struct nk_font_config *config_iter;
11361 int total_glyph_count = 0;
11362 int total_range_count = 0;
11363 int range_count = 0;
11366 NK_ASSERT(image_memory);
11369 NK_ASSERT(config_list);
11373 if (!image_memory || !width || !height || !config_list || !count)
return nk_false;
11374 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11375 range_count = nk_range_count(config_iter->range);
11376 total_range_count += range_count;
11377 total_glyph_count += nk_range_glyph_count(config_iter->range, range_count);
11381 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11382 const struct nk_font_config *cfg = config_iter;
11383 if (!nk_tt_InitFont(&baker->build[i++].info, (
const unsigned char*)cfg->ttf_blob, 0))
11388 *width = (total_glyph_count > 1000) ? 1024 : 512;
11389 nk_tt_PackBegin(&baker->spc, 0, (
int)*width, (
int)max_height, 0, 1, alloc);
11398 struct nk_rp_rect custom_space;
11399 nk_zero(&custom_space,
sizeof(custom_space));
11400 custom_space.w = (nk_rp_coord)((custom->
w * 2) + 1);
11401 custom_space.h = (nk_rp_coord)(custom->
h + 1);
11403 nk_tt_PackSetOversampling(&baker->spc, 1, 1);
11404 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, &custom_space, 1);
11405 *height =
NK_MAX(*height, (
int)(custom_space.y + custom_space.h));
11407 custom->
x = (short)custom_space.x;
11408 custom->
y = (
short)custom_space.y;
11409 custom->
w = (short)custom_space.w;
11410 custom->
h = (
short)custom_space.h;
11414 for (input_i = 0, config_iter = config_list; input_i < count && config_iter;
11415 input_i++, config_iter = config_iter->next)
11419 const nk_rune *in_range;
11420 const struct nk_font_config *cfg = config_iter;
11421 struct nk_font_bake_data *tmp = &baker->build[input_i];
11424 glyph_count = 0; range_count = 0;
11425 for (in_range = cfg->range; in_range[0] && in_range[1]; in_range += 2) {
11426 glyph_count += (
int)(in_range[1] - in_range[0]) + 1;
11431 tmp->ranges = baker->ranges + range_n;
11432 tmp->range_count = (
nk_rune)range_count;
11433 range_n += range_count;
11434 for (i = 0; i < range_count; ++i) {
11435 in_range = &cfg->range[i * 2];
11436 tmp->ranges[i].font_size = cfg->size;
11437 tmp->ranges[i].first_unicode_codepoint_in_range = (
int)in_range[0];
11438 tmp->ranges[i].num_chars = (
int)(in_range[1]- in_range[0]) + 1;
11439 tmp->ranges[i].chardata_for_range = baker->packed_chars + char_n;
11440 char_n += tmp->ranges[i].num_chars;
11444 tmp->rects = baker->rects + rect_n;
11445 rect_n += glyph_count;
11446 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
11447 n = nk_tt_PackFontRangesGatherRects(&baker->spc, &tmp->info,
11448 tmp->ranges, (
int)tmp->range_count, tmp->rects);
11449 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, tmp->rects, (
int)n);
11452 for (i = 0; i < n; ++i) {
11453 if (tmp->rects[i].was_packed)
11454 *height =
NK_MAX(*height, tmp->rects[i].y + tmp->rects[i].h);
11457 NK_ASSERT(rect_n == total_glyph_count);
11458 NK_ASSERT(char_n == total_glyph_count);
11459 NK_ASSERT(range_n == total_range_count);
11461 *height = (
int)nk_round_up_pow2((nk_uint)*height);
11467 nk_font_bake(
struct nk_font_baker *baker,
void *image_memory,
int width,
int height,
11468 struct nk_font_glyph *glyphs,
int glyphs_count,
11469 const struct nk_font_config *config_list,
int font_count)
11472 nk_rune glyph_n = 0;
11473 const struct nk_font_config *config_iter;
11475 NK_ASSERT(image_memory);
11478 NK_ASSERT(config_list);
11480 NK_ASSERT(font_count);
11481 NK_ASSERT(glyphs_count);
11482 if (!image_memory || !width || !height || !config_list ||
11483 !font_count || !glyphs || !glyphs_count)
11487 nk_zero(image_memory, (nk_size)((nk_size)width * (nk_size)height));
11488 baker->spc.pixels = (
unsigned char*)image_memory;
11489 baker->spc.height = (
int)height;
11490 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
11491 ++input_i, config_iter = config_iter->next)
11493 const struct nk_font_config *cfg = config_iter;
11494 struct nk_font_bake_data *tmp = &baker->build[input_i];
11495 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
11496 nk_tt_PackFontRangesRenderIntoRects(&baker->spc, &tmp->info, tmp->ranges,
11497 (
int)tmp->range_count, tmp->rects, &baker->alloc);
11499 nk_tt_PackEnd(&baker->spc, &baker->alloc);
11502 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
11503 ++input_i, config_iter = config_iter->next)
11507 nk_rune glyph_count = 0;
11508 const struct nk_font_config *cfg = config_iter;
11509 struct nk_font_bake_data *tmp = &baker->build[input_i];
11510 struct nk_baked_font *dst_font = cfg->font;
11512 float font_scale = nk_tt_ScaleForPixelHeight(&tmp->info, cfg->size);
11513 int unscaled_ascent, unscaled_descent, unscaled_line_gap;
11514 nk_tt_GetFontVMetrics(&tmp->info, &unscaled_ascent, &unscaled_descent,
11515 &unscaled_line_gap);
11518 if (!cfg->merge_mode) {
11519 dst_font->ranges = cfg->range;
11520 dst_font->height = cfg->size;
11521 dst_font->ascent = ((float)unscaled_ascent * font_scale);
11522 dst_font->descent = ((float)unscaled_descent * font_scale);
11523 dst_font->glyph_offset = glyph_n;
11527 for (i = 0; i < tmp->range_count; ++i)
11529 struct nk_tt_pack_range *range = &tmp->ranges[i];
11530 for (char_idx = 0; char_idx < range->num_chars; char_idx++)
11532 nk_rune codepoint = 0;
11533 float dummy_x = 0, dummy_y = 0;
11534 struct nk_tt_aligned_quad q;
11535 struct nk_font_glyph *glyph;
11538 const struct nk_tt_packedchar *pc = &range->chardata_for_range[char_idx];
11539 if (!pc->x0 && !pc->x1 && !pc->y0 && !pc->y1)
continue;
11540 codepoint = (
nk_rune)(range->first_unicode_codepoint_in_range + char_idx);
11541 nk_tt_GetPackedQuad(range->chardata_for_range, (
int)width,
11542 (
int)height, char_idx, &dummy_x, &dummy_y, &q, 0);
11545 glyph = &glyphs[dst_font->glyph_offset + (
unsigned int)glyph_count];
11546 glyph->codepoint = codepoint;
11547 glyph->x0 = q.x0; glyph->y0 = q.y0;
11548 glyph->x1 = q.x1; glyph->y1 = q.y1;
11549 glyph->y0 += (dst_font->ascent + 0.5f);
11550 glyph->y1 += (dst_font->ascent + 0.5f);
11551 glyph->w = glyph->x1 - glyph->x0 + 0.5f;
11552 glyph->h = glyph->y1 - glyph->y0;
11554 if (cfg->coord_type == NK_COORD_PIXEL) {
11555 glyph->u0 = q.s0 * (float)width;
11556 glyph->v0 = q.t0 * (float)height;
11557 glyph->u1 = q.s1 * (float)width;
11558 glyph->v1 = q.t1 * (float)height;
11565 glyph->xadvance = (pc->xadvance + cfg->spacing.x);
11566 if (cfg->pixel_snap)
11567 glyph->xadvance = (float)(
int)(glyph->xadvance + 0.5f);
11571 dst_font->glyph_count = glyph_count;
11572 glyph_n += dst_font->glyph_count;
11577 nk_font_bake_custom_data(
void *img_memory,
int img_width,
int img_height,
11578 struct nk_recti img_dst,
const char *texture_data_mask,
int tex_width,
11579 int tex_height,
char white,
char black)
11586 NK_ASSERT(img_memory);
11587 NK_ASSERT(img_width);
11588 NK_ASSERT(img_height);
11589 NK_ASSERT(texture_data_mask);
11591 if (!img_memory || !img_width || !img_height || !texture_data_mask)
11594 pixels = (nk_byte*)img_memory;
11595 for (y = 0, n = 0; y < tex_height; ++y) {
11596 for (x = 0; x < tex_width; ++x, ++n) {
11597 const int off0 = ((img_dst.
x + x) + (img_dst.
y + y) * img_width);
11598 const int off1 = off0 + 1 + tex_width;
11599 pixels[off0] = (texture_data_mask[n] == white) ? 0xFF : 0x00;
11600 pixels[off1] = (texture_data_mask[n] == black) ? 0xFF : 0x00;
11606 nk_font_bake_convert(
void *out_memory,
int img_width,
int img_height,
11607 const void *in_memory)
11611 const nk_byte *src;
11613 NK_ASSERT(out_memory);
11614 NK_ASSERT(in_memory);
11615 NK_ASSERT(img_width);
11616 NK_ASSERT(img_height);
11617 if (!out_memory || !in_memory || !img_height || !img_width)
return;
11619 dst = (nk_rune*)out_memory;
11620 src = (
const nk_byte*)in_memory;
11621 for (n = (
int)(img_width * img_height); n > 0; n--)
11622 *dst++ = ((nk_rune)(*src++) << 24) | 0x00FFFFFF;
11631 nk_font_text_width(nk_handle handle,
float height,
const char *text,
int len)
11635 float text_width = 0;
11639 struct nk_font *font = (
struct nk_font*)handle.
ptr;
11641 NK_ASSERT(font->glyphs);
11642 if (!font || !text || !len)
11645 scale = height/font->info.height;
11646 glyph_len = text_len =
nk_utf_decode(text, &unicode, (
int)len);
11647 if (!glyph_len)
return 0;
11648 while (text_len <= (
int)len && glyph_len) {
11649 const struct nk_font_glyph *g;
11653 g = nk_font_find_glyph(font, unicode);
11654 text_width += g->xadvance * scale;
11657 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)len - text_len);
11658 text_len += glyph_len;
11663 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
11665 nk_font_query_font_glyph(nk_handle handle,
float height,
11666 struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
11669 const struct nk_font_glyph *g;
11670 struct nk_font *font;
11675 font = (
struct nk_font*)handle.
ptr;
11677 NK_ASSERT(font->glyphs);
11678 if (!font || !glyph)
11681 scale = height/font->info.height;
11682 g = nk_font_find_glyph(font, codepoint);
11683 glyph->width = (g->x1 - g->x0) * scale;
11684 glyph->height = (g->y1 - g->y0) * scale;
11685 glyph->offset =
nk_vec2(g->x0 * scale, g->y0 * scale);
11686 glyph->xadvance = (g->xadvance * scale);
11687 glyph->uv[0] =
nk_vec2(g->u0, g->v0);
11688 glyph->uv[1] =
nk_vec2(g->u1, g->v1);
11692 NK_API const struct nk_font_glyph*
11693 nk_font_find_glyph(
struct nk_font *font, nk_rune unicode)
11697 int total_glyphs = 0;
11698 const struct nk_font_glyph *glyph = 0;
11701 NK_ASSERT(font->glyphs);
11702 NK_ASSERT(font->info.ranges);
11703 if (!font || !font->glyphs)
return 0;
11705 glyph = font->fallback;
11706 count = nk_range_count(font->info.ranges);
11707 for (i = 0; i < count; ++i) {
11708 nk_rune f = font->info.ranges[(i*2)+0];
11709 nk_rune t = font->info.ranges[(i*2)+1];
11710 int diff = (
int)((t - f) + 1);
11711 if (unicode >= f && unicode <= t)
11712 return &font->glyphs[((
nk_rune)total_glyphs + (unicode - f))];
11713 total_glyphs += diff;
11719 nk_font_init(
struct nk_font *font,
float pixel_height,
11720 nk_rune fallback_codepoint,
struct nk_font_glyph *glyphs,
11721 const struct nk_baked_font *baked_font, nk_handle atlas)
11723 struct nk_baked_font baked;
11726 NK_ASSERT(baked_font);
11727 if (!font || !glyphs || !baked_font)
11730 baked = *baked_font;
11731 font->fallback = 0;
11732 font->info = baked;
11733 font->scale = (float)pixel_height / (
float)font->info.height;
11734 font->glyphs = &glyphs[baked_font->glyph_offset];
11735 font->texture = atlas;
11736 font->fallback_codepoint = fallback_codepoint;
11737 font->fallback = nk_font_find_glyph(font, fallback_codepoint);
11739 font->handle.height = font->info.height * font->scale;
11740 font->handle.width = nk_font_text_width;
11741 font->handle.userdata.ptr = font;
11742 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
11743 font->handle.query = nk_font_query_font_glyph;
11744 font->handle.texture = font->texture;
11757 #ifdef NK_INCLUDE_DEFAULT_FONT
11760 #pragma clang diagnostic push
11762 #pragma clang diagnostic ignored "-Woverlength-strings"
11763 #elif defined(__GNUC__) || defined(__GNUG__)
11764 #pragma GCC diagnostic push
11765 #pragma GCC diagnostic ignored "-Woverlength-strings"
11768 NK_GLOBAL const char nk_proggy_clean_ttf_compressed_data_base85[11980+1] =
11769 "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
11770 "2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
11771 "`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
11772 "i@^rMl9t=cWq6##weg>$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;-<nLENhvx>-VsM.M0rJfLH2eTM`*oJMHRC`N"
11773 "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa<XCMKEV*N)LN/N"
11774 "*b=%Q6pia-Xg8I$<MR&,VdJe$<(7G;Ckl'&hF;;$<_=X(b.RS%%)###MPBuuE1V:v&cXm#(&cV]`k9OhLMbn%s$G2,B$BfD3X*sp5#l,$R#]x_X1xKX%b5U*[r5iMfUo9U`N99hG)"
11775 "tm+/Us9pG)XPu`<0s-)WTt(gCRxIg(%6sfh=ktMKn3j)<6<b5Sk_/0(^]AaN#(p/L>&VZ>1i%h1S9u5o@YaaW$e+b<TWFn/Z:Oh(Cx2$lNEoN^e)#CFY@@I;BOQ*sRwZtZxRcU7uW6CX"
11776 "ow0i(?$Q[cjOd[P4d)]>ROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc."
11777 "x]Ip.PH^'/aqUO/$1WxLoW0[iLA<QT;5HKD+@qQ'NQ(3_PLhE48R.qAPSwQ0/WK?Z,[x?-J;jQTWA0X@KJ(_Y8N-:/M74:/-ZpKrUss?d#dZq]DAbkU*JqkL+nwX@@47`5>w=4h(9.`G"
11778 "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?G<Nald$qs]@]L<J7bR*>gv:[7MI2k).'2($5FNP&EQ(,)"
11779 "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#"
11780 "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM"
11781 "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0<q-]L_?^)1vw'.,MRsqVr.L;aN&#/EgJ)PBc[-f>+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu"
11782 "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/"
11783 "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[K<L"
11784 "%a2E-grWVM3@2=-k22tL]4$##6We'8UJCKE[d_=%wI;'6X-GsLX4j^SgJ$##R*w,vP3wK#iiW&#*h^D&R?jp7+/u&#(AP##XU8c$fSYW-J95_-Dp[g9wcO&#M-h1OcJlc-*vpw0xUX&#"
11785 "OQFKNX@QI'IoPp7nb,QU//MQ&ZDkKP)X<WSVL(68uVl&#c'[0#(s1X&xm$Y%B7*K:eDA323j998GXbA#pwMs-jgD$9QISB-A_(aN4xoFM^@C58D0+Q+q3n0#3U1InDjF682-SjMXJK)("
11786 "h$hxua_K]ul92%'BOU&#BRRh-slg8KDlr:%L71Ka:.A;%YULjDPmL<LYs8i#XwJOYaKPKc1h:'9Ke,g)b),78=I39B;xiY$bgGw-&.Zi9InXDuYa%G*f2Bq7mn9^#p1vv%#(Wi-;/Z5h"
11787 "o;#2:;%d	v68C5g?ntX0X)pT`;%pB3q7mgGN)3%(P8nTd5L7GeA-GL@+%J3u2:(Yf>et`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO"
11788 "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J<j$UpK<Q4a1]MupW^-"
11789 "sj_$%[HK%'F####QRZJ::Y3EGl4'@%FkiAOg#p[##O`gukTfBHagL<LHw%q&OV0##F=6/:chIm0@eCP8X]:kFI%hl8hgO@RcBhS-@Qb$%+m=hPDLg*%K8ln(wcf3/'DW-$.lR?n[nCH-"
11790 "eXOONTJlh:.RYF%3'p6sq:UIMA945&^HFS87@$EP2iG<-lCO$%c`uKGD3rC$x0BL8aFn--`ke%#HMP'vh1/R&O_J9'um,.<tx[@%wsJk&bUT2`0uMv7gg#qp/ij.L56'hl;.s5CUrxjO"
11791 "M7-##.l+Au'A&O:-T72L]P`&=;ctp'XScX*rU.>-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%"
11792 "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$M<Jnq79VsJW/mWS*PUiq76;]/NM_>hLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]"
11793 "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et"
11794 "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$<M-SGZ':+Q_k+uvOSLiEo(<aD/K<CCc`'Lx>'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:"
11795 "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VB<HFF*qL("
11796 "$/V,;(kXZejWO`<[5?\?ewY(*9=%wDc;,u<'9t3W-(H1th3+G]ucQ]kLs7df($/*JL]@*t7Bu_G3_7mp7<iaQjO@.kLg;x3B0lqp7Hf,^Ze7-##@/c58Mo(3;knp0%)A7?-W+eI'o8)b<"
11797 "nKnw'Ho8C=Y>pqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<<aG/1N$#FX$0V5Y6x'aErI3I$7x%E`v<-BY,)%-?Psf*l?%C3.mM(=/M0:JxG'?"
11798 "7WhH%o'a<-80g0NBxoO(GH<dM]n.+%q@jH?f.UsJ2Ggs&4<-e47&Kl+f//9@`b+?.TeN_&B8Ss?v;^Trk;f#YvJkl&w$]>-+k?'(<S:68tq*WoDfZu';mM?8X[ma8W%*`-=;D.(nc7/;"
11799 ")g:T1=^J$&BRV(-lTmNB6xqB[@0*o.erM*<SWF]u2=st-*(6v>^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M"
11800 "D?@f&1'BW-)Ju<L25gl8uhVm1hL$##*8###'A3/LkKW+(^rWX?5W_8g)a(m&K8P>#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX("
11801 "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs"
11802 "bIu)'Z,*[>br5fX^:FPAWr-m2KgL<LUN098kTF&#lvo58=/vjDo;.;)Ka*hLR#/k=rKbxuV`>Q_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q"
11803 "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aeg<Z'<$#4H)6,>e0jT6'N#(q%.O=?2S]u*(m<-"
11804 "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i"
11805 "sZ88+dKQ)W6>J%CL<KE>`.d*(B`-n8D9oK<Up]c$X$(,)M8Zt7/[rdkqTgl-0cuGMv'?>-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P	r+$%CE=68>K8r0=dSC%%(@p7"
11806 ".m7jilQ02'0-VWAg<a/''3u.=4L$Y)6k/K:_[3=&jvL<L0C/2'v:^;-DIBW,B4E68:kZ;%?8(Q8BH=kO65BW?xSG&#@uU,DS*,?.+(o(#1vCS8#CHF>TlGW'b)Tq7VT9q^*^$$.:&N@@"
11807 "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*"
11808 "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u"
11809 "@-W$U%VEQ/,,>>#)D<h#`)h0:<Q6909ua+&VU%n2:cG3FJ-%@Bj-DgLr`Hw&HAKjKjseK</xKT*)B,N9X3]krc12t'pgTV(Lv-tL[xg_%=M_q7a^x?7Ubd>#%8cY#YZ?=,`Wdxu/ae&#"
11810 "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$s<Eh#c&)q.MXI%#v9ROa5FZO%sF7q7Nwb&#ptUJ:aqJe$Sl68%.D###EC><?-aF&#RNQv>o8lKN%5/$(vdfq7+ebA#"
11811 "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(<c`Q8N)jEIF*+?P2a8g%)$q]o2aH8C&<SibC/q,(e:v;-b#6[$NtDZ84Je2KNvB#$P5?tQ3nt(0"
11812 "d=j.LQf./Ll33+(;q3L-w=8dX$#WF&uIJ@-bfI>%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8"
11813 "6e%B/:=>)N4xeW.*wft-;$'58-ESqr<b?UI(_%@[P46>#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#"
11814 "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjL<Lni;''X.`$#8+1GD"
11815 ":k$YUWsbn8ogh6rxZ2Z9]%nd+>V#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#<NEdtg(n'=S1A(Q1/I&4([%dM`,Iu'1:_hL>SfD07&6D<fp8dHM7/g+"
11816 "tlPN9J*rKaPct&?'uBCem^jn%9_K)<,C5K3s=5g&GmJb*[SYq7K;TRLGCsM-$$;S%:Y@r7AK0pprpL<Lrh,q7e/%KWK:50I^+m'vi`3?%Zp+<-d+$L-Sv:@.o19n$s0&39;kn;S%BSq*"
11817 "$3WoJSCLweV[aZ'MQIjO<7;X-X;&+dMLvu#^UsGEC9WEc[X(wI7#2.(F0jV*eZf<-Qv3J-c+J5AlrB#$p(H68LvEA'q3n0#m,[`*8Ft)FcYgEud]CWfm68,(aLA$@EFTgLXoBq/UPlp7"
11818 ":d[/;r_ix=:TF`S5H-b<LI&HY(K=h#)]Lk$K14lVfm:x$H<3^Ql<M`$OhapBnkup'D#L$Pb_`N*g]2e;X/Dtg,bsj&K#2[-:iYr'_wgH)NUIR8a1n#S?Yej'h8^58UbZd+^FKD*T@;6A"
11819 "7aQC[K8d-(v6GI$x:T<&'Gp5Uf>@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-<aN((^7('#Z0wK#5GX@7"
11820 "u][`*S^43933A4rl][`*O4CgLEl]v$1Q3AeF37dbXk,.)vj#x'd`;qgbQR%FW,2(?LO=s%Sc68%NP'##Aotl8x=BE#j1UD([3$M(]UI2LX3RpKN@;/#f'f/&_mt&F)XdF<9t4)Qa.*kT"
11821 "LwQ'(TTB9.xH'>#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5<N?)NBS)QN*_I,?&)2'IM%L3I)X((e/dl2&8'<M"
11822 ":^#M*Q+[T.Xri.LYS3v%fF`68h;b-X[/En'CR.q7E)p'/kle2HM,u;^%OKC-N+Ll%F9CF<Nf'^#t2L,;27W:0O@6##U6W7:$rJfLWHj$#)woqBefIZ.PK<b*t7ed;p*_m;4ExK#h@&]>"
11823 "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%"
11824 "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;"
11825 "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmL<LD)F^%[tC'8;+9E#C$g%#5Y>q9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:"
11826 "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3<n-&%H%b<FDj2M<hH=&Eh<2Len$b*aTX=-8QxN)k11IM1c^j%"
11827 "9s<L<NFSo)B?+<-(GxsF,^-Eh@$4dXhN$+#rxK8'je'D7k`e;)2pYwPA'_p9&@^18ml1^[@g4t*[JOa*[=Qp7(qJ_oOL^('7fB&Hq-:sf,sNj8xq^>$U4O]GKx'm9)b@p7YsvK3w^YR-"
11828 "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*"
11829 "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdF<TddF<9Ah-6&9tWoDlh]&1SpGMq>Ti1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IX<N+T+0MlMBPQ*Vj>SsD<U4JHY"
11830 "8kD2)2fU/M#$e.)T4,_=8hLim[&);?UkK'-x?'(:siIfL<$pFM`i<?%W(mGDHM%>iWP,##P`%/L<eXi:@Z9C.7o=@(pXdAO/NLQ8lPl+HPOQa8wD8=^GlPa8TKI1CjhsCTSLJM'/Wl>-"
11831 "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n<bhPmUkMw>%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL<LoNs'6,'85`"
11832 "0?t/'_U59@]ddF<#LdF<eWdF<OuN/45rY<-L@&#+fm>69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdF<gR@2L=FNU-<b[(9c/ML3m;Z[$oF3g)GAWqpARc=<ROu7cL5l;-[A]%/"
11833 "+fsd;l#SafT/f*W]0=O'$(Tb<[)*@e775R-:Yob%g*>l*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj"
11834 "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#<IGe;__.thjZl<%w(Wk2xmp4Q@I#I9,DF]u7-P=.-_:YJ]aS@V"
11835 "?6*C()dOp7:WL,b&3Rg/.cmM9&r^>$(>.Z-I&J(Q0Hd5Q%7Co-b`-c<N(6r@ip+AurK<m86QIth*#v;-OBqi+L7wDE-Ir8K['m+DDSLwK&/.?-V%U_%3:qKNu$_b*B-kp7NaD'QdWQPK"
11836 "Yq[@>P)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8<FfNkgg^oIbah*#8/Qt$F&:K*-(N/'+1vMB,u()-a.VUU*#[e%gAAO(S>WlA2);Sa"
11837 ">gXm8YB`1d@K#n]76-a$U,mF<fX]idqd)<3,]J7JmW4`6]uks=4-72L(jEk+:bJ0M^q-8Dm_Z?0olP1C9Sa&H[d&c$ooQUj]Exd*3ZM@-WGW2%s',B-_M%>%Ul:#/'xoFM9QX-$.QN'>"
11838 "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B</R90;eZ]%Ncq;-Tl]#F>2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I"
11839 "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1<Vc52=u`3^o-n1'g4v58Hj&6_t7$##?M)c<$bgQ_'SY((-xkA#"
11840 "Y(,p'H9rIVY-b,'%bCPF7.J<Up^,(dU1VY*5#WkTU>h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-u<Hp,3@e^9UB1J+ak9-TN/mhKPg+AJYd$"
11841 "MlvAF_jCK*.O-^(63adMT->W%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)"
11842 "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo"
11843 "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P"
11844 "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*<h`e-GI7)?OK2A.d7_c)?wQ5AS@DL3r#7fSkgl6-++D:'A,uq7SvlB$pcpH'q3n0#_%dY#xCpr-l<F0NR@-##FEV6NTF6##$l84N1w?AO>'IAO"
11845 "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#"
11846 ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T<XoIB&hx=T1PcDaB&;HH+-AFr?(m9HZV)FKS8JCw;SD=6[^/DZUL`EUDf]GGlG&>"
11847 "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#<xU?#@.i?#D:%@#HF7@#LRI@#P_[@#Tkn@#Xw*A#]-=A#a9OA#"
11848 "d<F&#*;G##.GY##2Sl##6`($#:l:$#>xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4"
11849 "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#"
11850 "/QHC#3^ZC#7jmC#;v)D#?,<D#C8ND#GDaD#KPsD#O]/E#g1A5#KA*1#gC17#MGd;#8(02#L-d3#rWM4#Hga1#,<w0#T.j<#O#'2#CYN1#qa^:#_4m3#o@/=#eG8=#t8J5#`+78#4uI-#"
11851 "m3B2#SB[8#Q0@8#i[*9#iOn8#1Nm;#^sN9#qh<9#:=x-#P;K2#$%X9#bC+.#Rg;<#mN=.#MTF.#RZO.#2?)4#Y#(/#[)1/#b;L/#dAU/#0Sv;#lY$0#n`-0#sf60#(F24#wrH0#%/e0#"
11852 "TmD<#%JSMFove:CTBEXI:<eh2g)B,3h2^G3i;#d3jD>)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP"
11853 "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp"
11854 "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
11857 #define NK_CURSOR_DATA_W 90
11858 #define NK_CURSOR_DATA_H 27
11859 NK_GLOBAL const char nk_custom_cursor_data[NK_CURSOR_DATA_W * NK_CURSOR_DATA_H + 1] =
11861 "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX"
11862 "..- -X.....X- X.X - X.X -X.....X - X.....X"
11863 "--- -XXX.XXX- X...X - X...X -X....X - X....X"
11864 "X - X.X - X.....X - X.....X -X...X - X...X"
11865 "XX - X.X -X.......X- X.......X -X..X.X - X.X..X"
11866 "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X"
11867 "X..X - X.X - X.X - X.X -XX X.X - X.X XX"
11868 "X...X - X.X - X.X - XX X.X XX - X.X - X.X "
11869 "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X "
11870 "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X "
11871 "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X "
11872 "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X "
11873 "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X "
11874 "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X "
11875 "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X "
11876 "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X "
11877 "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX "
11878 "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------"
11879 "X.X X..X - -X.......X- X.......X - XX XX - "
11880 "XX X..X - - X.....X - X.....X - X.X X.X - "
11881 " X..X - X...X - X...X - X..X X..X - "
11882 " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - "
11883 "------------ - X - X -X.....................X- "
11884 " ----------------------------------- X...XXXXXXXXXXXXX...X - "
11891 #pragma clang diagnostic pop
11892 #elif defined(__GNUC__) || defined(__GNUG__)
11893 #pragma GCC diagnostic pop
11897 nk_decompress_length(
unsigned char *input)
11899 return (
unsigned int)((input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]);
11909 nk__match(
unsigned char *data,
unsigned int length)
11912 NK_ASSERT (nk__dout + length <= nk__barrier);
11913 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
11914 if (data < nk__barrier4) { nk__dout = nk__barrier+1;
return; }
11915 while (length--) *nk__dout++ = *data++;
11919 nk__lit(
unsigned char *data,
unsigned int length)
11921 NK_ASSERT (nk__dout + length <= nk__barrier);
11922 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
11923 if (data < nk__barrier2) { nk__dout = nk__barrier+1;
return; }
11924 NK_MEMCPY(nk__dout, data, length);
11925 nk__dout += length;
11928 #define nk__in2(x) ((i[x] << 8) + i[(x)+1])
11929 #define nk__in3(x) ((i[x] << 16) + nk__in2((x)+1))
11930 #define nk__in4(x) ((i[x] << 24) + nk__in3((x)+1))
11933 nk_decompress_token(
unsigned char *i)
11936 if (*i >= 0x80) nk__match(nk__dout-i[1]-1, (
unsigned int)i[0] - 0x80 + 1), i += 2;
11937 else if (*i >= 0x40) nk__match(nk__dout-(nk__in2(0) - 0x4000 + 1), (
unsigned int)i[2]+1), i += 3;
11938 else nk__lit(i+1, (
unsigned int)i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
11940 if (*i >= 0x18) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x180000 + 1), (
unsigned int)i[3]+1), i += 4;
11941 else if (*i >= 0x10) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x100000 + 1), (
unsigned int)nk__in2(3)+1), i += 5;
11942 else if (*i >= 0x08) nk__lit(i+2, (
unsigned int)nk__in2(0) - 0x0800 + 1), i += 2 + (nk__in2(0) - 0x0800 + 1);
11943 else if (*i == 0x07) nk__lit(i+3, (
unsigned int)nk__in2(1) + 1), i += 3 + (nk__in2(1) + 1);
11944 else if (*i == 0x06) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), i[4]+1u), i += 5;
11945 else if (*i == 0x04) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), (
unsigned int)nk__in2(4)+1u), i += 6;
11951 nk_adler32(
unsigned int adler32,
unsigned char *buffer,
unsigned int buflen)
11953 const unsigned long ADLER_MOD = 65521;
11954 unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
11955 unsigned long blocklen, i;
11957 blocklen = buflen % 5552;
11959 for (i=0; i + 7 < blocklen; i += 8) {
11960 s1 += buffer[0]; s2 += s1;
11961 s1 += buffer[1]; s2 += s1;
11962 s1 += buffer[2]; s2 += s1;
11963 s1 += buffer[3]; s2 += s1;
11964 s1 += buffer[4]; s2 += s1;
11965 s1 += buffer[5]; s2 += s1;
11966 s1 += buffer[6]; s2 += s1;
11967 s1 += buffer[7]; s2 += s1;
11970 for (; i < blocklen; ++i) {
11971 s1 += *buffer++; s2 += s1;
11974 s1 %= ADLER_MOD; s2 %= ADLER_MOD;
11975 buflen -= (
unsigned int)blocklen;
11978 return (
unsigned int)(s2 << 16) + (
unsigned int)s1;
11982 nk_decompress(
unsigned char *output,
unsigned char *i,
unsigned int length)
11985 if (nk__in4(0) != 0x57bC0000)
return 0;
11986 if (nk__in4(4) != 0)
return 0;
11987 olen = nk_decompress_length(i);
11989 nk__barrier3 = i+length;
11990 nk__barrier = output + olen;
11996 unsigned char *old_i = i;
11997 i = nk_decompress_token(i);
11999 if (*i == 0x05 && i[1] == 0xfa) {
12000 NK_ASSERT(nk__dout == output + olen);
12001 if (nk__dout != output + olen)
return 0;
12002 if (nk_adler32(1, output, olen) != (
unsigned int) nk__in4(2))
12010 NK_ASSERT(nk__dout <= output + olen);
12011 if (nk__dout > output + olen)
12017 nk_decode_85_byte(
char c)
12018 {
return (
unsigned int)((c >=
'\\') ? c-36 : c-35); }
12021 nk_decode_85(
unsigned char* dst,
const unsigned char* src)
12026 nk_decode_85_byte((
char)src[0]) +
12027 85 * (nk_decode_85_byte((
char)src[1]) +
12028 85 * (nk_decode_85_byte((
char)src[2]) +
12029 85 * (nk_decode_85_byte((
char)src[3]) +
12030 85 * nk_decode_85_byte((
char)src[4]))));
12033 dst[0] = (
unsigned char)((tmp >> 0) & 0xFF);
12034 dst[1] = (
unsigned char)((tmp >> 8) & 0xFF);
12035 dst[2] = (
unsigned char)((tmp >> 16) & 0xFF);
12036 dst[3] = (
unsigned char)((tmp >> 24) & 0xFF);
12048 NK_API struct nk_font_config
12049 nk_font_config(float pixel_height)
12051 struct nk_font_config cfg;
12055 cfg.ttf_data_owned_by_atlas = 0;
12056 cfg.size = pixel_height;
12057 cfg.oversample_h = 3;
12058 cfg.oversample_v = 1;
12059 cfg.pixel_snap = 0;
12060 cfg.coord_type = NK_COORD_UV;
12062 cfg.range = nk_font_default_glyph_ranges();
12063 cfg.merge_mode = 0;
12064 cfg.fallback_glyph =
'?';
12069 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
12071 nk_font_atlas_init_default(
struct nk_font_atlas *atlas)
12074 if (!atlas)
return;
12076 atlas->temporary.userdata.ptr = 0;
12077 atlas->temporary.alloc = nk_malloc;
12078 atlas->temporary.free = nk_mfree;
12079 atlas->permanent.userdata.ptr = 0;
12080 atlas->permanent.alloc = nk_malloc;
12081 atlas->permanent.free = nk_mfree;
12086 nk_font_atlas_init(
struct nk_font_atlas *atlas,
struct nk_allocator *alloc)
12090 if (!atlas || !alloc)
return;
12092 atlas->permanent = *alloc;
12093 atlas->temporary = *alloc;
12097 nk_font_atlas_init_custom(
struct nk_font_atlas *atlas,
12101 NK_ASSERT(permanent);
12102 NK_ASSERT(temporary);
12103 if (!atlas || !permanent || !temporary)
return;
12105 atlas->permanent = *permanent;
12106 atlas->temporary = *temporary;
12110 nk_font_atlas_begin(
struct nk_font_atlas *atlas)
12113 NK_ASSERT(atlas->temporary.alloc && atlas->temporary.free);
12114 NK_ASSERT(atlas->permanent.alloc && atlas->permanent.free);
12115 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free ||
12116 !atlas->temporary.alloc || !atlas->temporary.free)
return;
12117 if (atlas->glyphs) {
12118 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
12121 if (atlas->pixel) {
12122 atlas->permanent.free(atlas->permanent.userdata, atlas->pixel);
12128 nk_font_atlas_add(
struct nk_font_atlas *atlas,
const struct nk_font_config *config)
12130 struct nk_font *font = 0;
12131 struct nk_font_config *cfg;
12134 NK_ASSERT(atlas->permanent.alloc);
12135 NK_ASSERT(atlas->permanent.free);
12136 NK_ASSERT(atlas->temporary.alloc);
12137 NK_ASSERT(atlas->temporary.free);
12140 NK_ASSERT(config->ttf_blob);
12141 NK_ASSERT(config->ttf_size);
12142 NK_ASSERT(config->size > 0.0f);
12144 if (!atlas || !config || !config->ttf_blob || !config->ttf_size || config->size <= 0.0f||
12145 !atlas->permanent.alloc || !atlas->permanent.free ||
12146 !atlas->temporary.alloc || !atlas->temporary.free)
12150 cfg = (
struct nk_font_config*)
12151 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font_config));
12152 NK_MEMCPY(cfg, config,
sizeof(*config));
12153 if (!atlas->config) {
12154 atlas->config = cfg;
12157 cfg->next = atlas->config;
12158 atlas->config = cfg;
12162 if (!config->merge_mode) {
12163 font = (
struct nk_font*)
12164 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font));
12166 if (!font)
return 0;
12167 font->config = cfg;
12169 NK_ASSERT(atlas->font_num);
12170 font = atlas->fonts;
12171 font->config = cfg;
12175 if (!config->merge_mode) {
12176 if (!atlas->fonts) {
12177 atlas->fonts = font;
12180 font->next = atlas->fonts;
12181 atlas->fonts = font;
12183 cfg->font = &font->info;
12187 if (!config->ttf_data_owned_by_atlas) {
12188 cfg->ttf_blob = atlas->permanent.alloc(atlas->permanent.userdata,0, cfg->ttf_size);
12189 NK_ASSERT(cfg->ttf_blob);
12190 if (!cfg->ttf_blob) {
12194 NK_MEMCPY(cfg->ttf_blob, config->ttf_blob, cfg->ttf_size);
12195 cfg->ttf_data_owned_by_atlas = 1;
12202 nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory,
12203 nk_size size,
float height,
const struct nk_font_config *config)
12205 struct nk_font_config cfg;
12210 NK_ASSERT(atlas->temporary.alloc);
12211 NK_ASSERT(atlas->temporary.free);
12212 NK_ASSERT(atlas->permanent.alloc);
12213 NK_ASSERT(atlas->permanent.free);
12214 if (!atlas || !atlas->temporary.alloc || !atlas->temporary.free || !memory || !size ||
12215 !atlas->permanent.alloc || !atlas->permanent.free)
12218 cfg = (
config) ? *config: nk_font_config(height);
12219 cfg.ttf_blob = memory;
12220 cfg.ttf_size = size;
12222 cfg.ttf_data_owned_by_atlas = 0;
12223 return nk_font_atlas_add(atlas, &cfg);
12226 #ifdef NK_INCLUDE_STANDARD_IO
12228 nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
12229 float height,
const struct nk_font_config *config)
12233 struct nk_font_config cfg;
12236 NK_ASSERT(atlas->temporary.alloc);
12237 NK_ASSERT(atlas->temporary.free);
12238 NK_ASSERT(atlas->permanent.alloc);
12239 NK_ASSERT(atlas->permanent.free);
12241 if (!atlas || !file_path)
return 0;
12242 memory = nk_file_load(file_path, &size, &atlas->permanent);
12243 if (!memory)
return 0;
12245 cfg = (
config) ? *config: nk_font_config(height);
12246 cfg.ttf_blob = memory;
12247 cfg.ttf_size = size;
12249 cfg.ttf_data_owned_by_atlas = 1;
12250 return nk_font_atlas_add(atlas, &cfg);
12255 nk_font_atlas_add_compressed(
struct nk_font_atlas *atlas,
12256 void *compressed_data, nk_size compressed_size,
float height,
12257 const struct nk_font_config *config)
12259 unsigned int decompressed_size;
12260 void *decompressed_data;
12261 struct nk_font_config cfg;
12264 NK_ASSERT(atlas->temporary.alloc);
12265 NK_ASSERT(atlas->temporary.free);
12266 NK_ASSERT(atlas->permanent.alloc);
12267 NK_ASSERT(atlas->permanent.free);
12269 NK_ASSERT(compressed_data);
12270 NK_ASSERT(compressed_size);
12271 if (!atlas || !compressed_data || !atlas->temporary.alloc || !atlas->temporary.free ||
12272 !atlas->permanent.alloc || !atlas->permanent.free)
12275 decompressed_size = nk_decompress_length((
unsigned char*)compressed_data);
12276 decompressed_data = atlas->permanent.alloc(atlas->permanent.userdata,0,decompressed_size);
12277 NK_ASSERT(decompressed_data);
12278 if (!decompressed_data)
return 0;
12279 nk_decompress((
unsigned char*)decompressed_data, (
unsigned char*)compressed_data,
12280 (
unsigned int)compressed_size);
12282 cfg = (
config) ? *config: nk_font_config(height);
12283 cfg.ttf_blob = decompressed_data;
12284 cfg.ttf_size = decompressed_size;
12286 cfg.ttf_data_owned_by_atlas = 1;
12287 return nk_font_atlas_add(atlas, &cfg);
12291 nk_font_atlas_add_compressed_base85(
struct nk_font_atlas *atlas,
12292 const char *data_base85,
float height,
const struct nk_font_config *config)
12294 int compressed_size;
12295 void *compressed_data;
12296 struct nk_font *font;
12299 NK_ASSERT(atlas->temporary.alloc);
12300 NK_ASSERT(atlas->temporary.free);
12301 NK_ASSERT(atlas->permanent.alloc);
12302 NK_ASSERT(atlas->permanent.free);
12304 NK_ASSERT(data_base85);
12305 if (!atlas || !data_base85 || !atlas->temporary.alloc || !atlas->temporary.free ||
12306 !atlas->permanent.alloc || !atlas->permanent.free)
12309 compressed_size = (((
int)
nk_strlen(data_base85) + 4) / 5) * 4;
12310 compressed_data = atlas->temporary.alloc(atlas->temporary.userdata,0, (nk_size)compressed_size);
12311 NK_ASSERT(compressed_data);
12312 if (!compressed_data)
return 0;
12313 nk_decode_85((
unsigned char*)compressed_data, (
const unsigned char*)data_base85);
12314 font = nk_font_atlas_add_compressed(atlas, compressed_data,
12315 (nk_size)compressed_size, height, config);
12316 atlas->temporary.free(atlas->temporary.userdata, compressed_data);
12320 #ifdef NK_INCLUDE_DEFAULT_FONT
12322 nk_font_atlas_add_default(
struct nk_font_atlas *atlas,
12323 float pixel_height,
const struct nk_font_config *config)
12326 NK_ASSERT(atlas->temporary.alloc);
12327 NK_ASSERT(atlas->temporary.free);
12328 NK_ASSERT(atlas->permanent.alloc);
12329 NK_ASSERT(atlas->permanent.free);
12330 return nk_font_atlas_add_compressed_base85(atlas,
12331 nk_proggy_clean_ttf_compressed_data_base85, pixel_height, config);
12336 nk_font_atlas_bake(
struct nk_font_atlas *atlas,
int *width,
int *height,
12337 enum nk_font_atlas_format fmt)
12341 nk_size tmp_size, img_size;
12342 struct nk_font *font_iter;
12343 struct nk_font_baker *baker;
12346 NK_ASSERT(atlas->temporary.alloc);
12347 NK_ASSERT(atlas->temporary.free);
12348 NK_ASSERT(atlas->permanent.alloc);
12349 NK_ASSERT(atlas->permanent.free);
12353 if (!atlas || !width || !height ||
12354 !atlas->temporary.alloc || !atlas->temporary.free ||
12355 !atlas->permanent.alloc || !atlas->permanent.free)
12358 #ifdef NK_INCLUDE_DEFAULT_FONT
12360 if (!atlas->font_num)
12361 atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
12363 NK_ASSERT(atlas->font_num);
12364 if (!atlas->font_num)
return 0;
12367 nk_font_baker_memory(&tmp_size, &atlas->glyph_count, atlas->config, atlas->font_num);
12368 tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
12370 if (!tmp)
goto failed;
12373 baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);
12374 atlas->glyphs = (
struct nk_font_glyph*)atlas->permanent.alloc(
12375 atlas->permanent.userdata,0,
sizeof(
struct nk_font_glyph)*(nk_size)atlas->glyph_count);
12376 NK_ASSERT(atlas->glyphs);
12377 if (!atlas->glyphs)
12381 atlas->custom.w = (NK_CURSOR_DATA_W*2)+1;
12382 atlas->custom.h = NK_CURSOR_DATA_H + 1;
12383 if (!nk_font_bake_pack(baker, &img_size, width, height, &atlas->custom,
12384 atlas->config, atlas->font_num, &atlas->temporary))
12388 atlas->pixel = atlas->temporary.alloc(atlas->temporary.userdata,0, img_size);
12389 NK_ASSERT(atlas->pixel);
12394 nk_font_bake(baker, atlas->pixel, *width, *height,
12395 atlas->glyphs, atlas->glyph_count, atlas->config, atlas->font_num);
12396 nk_font_bake_custom_data(atlas->pixel, *width, *height, atlas->custom,
12397 nk_custom_cursor_data, NK_CURSOR_DATA_W, NK_CURSOR_DATA_H,
'.',
'X');
12399 if (fmt == NK_FONT_ATLAS_RGBA32) {
12401 void *img_rgba = atlas->temporary.alloc(atlas->temporary.userdata,0,
12402 (nk_size)(*width * *height * 4));
12403 NK_ASSERT(img_rgba);
12404 if (!img_rgba)
goto failed;
12405 nk_font_bake_convert(img_rgba, *width, *height, atlas->pixel);
12406 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12407 atlas->pixel = img_rgba;
12409 atlas->tex_width = *width;
12410 atlas->tex_height = *height;
12413 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
12414 struct nk_font *font = font_iter;
12415 struct nk_font_config *config = font->config;
12416 nk_font_init(font, config->size, config->fallback_glyph, atlas->glyphs,
12423 {{ 0, 3}, {12,19}, { 0, 0}},
12424 {{13, 0}, { 7,16}, { 4, 8}},
12425 {{31, 0}, {23,23}, {11,11}},
12426 {{21, 0}, { 9, 23}, { 5,11}},
12427 {{55,18}, {23, 9}, {11, 5}},
12428 {{73, 0}, {17,17}, { 9, 9}},
12429 {{55, 0}, {17,17}, { 9, 9}}
12432 struct nk_cursor *cursor = &atlas->cursors[i];
12433 cursor->
img.
w = (
unsigned short)*width;
12434 cursor->
img.
h = (
unsigned short)*height;
12435 cursor->
img.
region[0] = (
unsigned short)(atlas->custom.x + nk_cursor_data[i][0].
x);
12436 cursor->
img.
region[1] = (
unsigned short)(atlas->custom.y + nk_cursor_data[i][0].
y);
12437 cursor->
img.
region[2] = (
unsigned short)nk_cursor_data[i][1].x;
12438 cursor->
img.
region[3] = (
unsigned short)nk_cursor_data[i][1].y;
12439 cursor->size = nk_cursor_data[i][1];
12440 cursor->
offset = nk_cursor_data[i][2];
12443 atlas->temporary.free(atlas->temporary.userdata, tmp);
12444 return atlas->pixel;
12448 if (tmp) atlas->temporary.free(atlas->temporary.userdata, tmp);
12449 if (atlas->glyphs) {
12450 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
12453 if (atlas->pixel) {
12454 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12461 nk_font_atlas_end(
struct nk_font_atlas *atlas, nk_handle texture,
12465 struct nk_font *font_iter;
12474 null->
uv.
x = (atlas->custom.x + 0.5f)/(
float)atlas->tex_width;
12475 null->
uv.
y = (atlas->custom.y + 0.5f)/(
float)atlas->tex_height;
12477 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
12478 font_iter->texture =
texture;
12479 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
12480 font_iter->handle.texture =
texture;
12484 atlas->cursors[i].img.handle = texture;
12486 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12488 atlas->tex_width = 0;
12489 atlas->tex_height = 0;
12490 atlas->custom.x = 0;
12491 atlas->custom.y = 0;
12492 atlas->custom.w = 0;
12493 atlas->custom.h = 0;
12497 nk_font_atlas_cleanup(
struct nk_font_atlas *atlas)
12500 NK_ASSERT(atlas->temporary.alloc);
12501 NK_ASSERT(atlas->temporary.free);
12502 NK_ASSERT(atlas->permanent.alloc);
12503 NK_ASSERT(atlas->permanent.free);
12505 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
12506 if (atlas->config) {
12507 struct nk_font_config *iter, *next;
12508 for (iter = atlas->config; iter; iter = next) {
12510 atlas->permanent.free(atlas->permanent.userdata, iter->ttf_blob);
12511 atlas->permanent.free(atlas->permanent.userdata, iter);
12518 nk_font_atlas_clear(
struct nk_font_atlas *atlas)
12521 NK_ASSERT(atlas->temporary.alloc);
12522 NK_ASSERT(atlas->temporary.free);
12523 NK_ASSERT(atlas->permanent.alloc);
12524 NK_ASSERT(atlas->permanent.free);
12525 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
12527 nk_font_atlas_cleanup(atlas);
12528 if (atlas->fonts) {
12529 struct nk_font *iter, *next;
12530 for (iter = atlas->fonts; iter; iter = next) {
12532 atlas->permanent.free(atlas->permanent.userdata, iter);
12537 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
12822 struct nk_text_find {
12825 int first_char, length;
12829 struct nk_text_edit_row {
12832 float baseline_y_delta;
12843 #define NK_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
12846 nk_textedit_get_width(
const struct nk_text_edit *edit,
int line_start,
int char_id,
12850 nk_rune unicode = 0;
12856 nk_textedit_layout_row(
struct nk_text_edit_row *r,
struct nk_text_edit *edit,
12857 int line_start_id,
float row_height,
const struct nk_user_font *font)
12862 const char *remaining;
12866 const struct nk_vec2 size = nk_text_calculate_text_bounds(font,
12867 text, (
int)(end - text), row_height, &remaining, 0, &glyphs, NK_STOP_ON_NEW_LINE);
12871 r->baseline_y_delta = size.
y;
12874 r->num_chars = glyphs;
12878 nk_textedit_locate_coord(
struct nk_text_edit *edit,
float x,
float y,
12881 struct nk_text_edit_row r;
12883 float base_y = 0, prev_x;
12887 r.ymin = r.ymax = 0;
12892 nk_textedit_layout_row(&r, edit, i, row_height, font);
12893 if (r.num_chars <= 0)
12896 if (i==0 && y < base_y + r.ymin)
12899 if (y < base_y + r.ymax)
12903 base_y += r.baseline_y_delta;
12919 for (i=0; i < r.num_chars; ++i) {
12920 float w = nk_textedit_get_width(edit, k, i, font);
12921 if (x < prev_x+w) {
12922 if (x < prev_x+w/2)
12934 return i+r.num_chars-1;
12935 else return i+r.num_chars;
12939 nk_textedit_click(
struct nk_text_edit *state,
float x,
float y,
12944 state->
cursor = nk_textedit_locate_coord(state, x, y, font, row_height);
12951 nk_textedit_drag(
struct nk_text_edit *state,
float x,
float y,
12956 int p = nk_textedit_locate_coord(state, x, y, font, row_height);
12963 nk_textedit_find_charpos(
struct nk_text_find *find,
struct nk_text_edit *state,
12964 int n,
int single_line,
const struct nk_user_font *font,
float row_height)
12968 struct nk_text_edit_row r;
12969 int prev_start = 0;
12977 nk_textedit_layout_row(&r, state, 0, row_height, font);
12979 find->first_char = 0;
12985 nk_textedit_layout_row(&r, state, i, row_height, font);
12988 find->first_char = i;
12989 find->length = r.num_chars;
12993 find->height = r.ymax - r.ymin;
12994 find->prev_first = prev_start;
13002 nk_textedit_layout_row(&r, state, i, row_height, font);
13003 if (n < i + r.num_chars)
break;
13006 find->y += r.baseline_y_delta;
13009 find->first_char = first = i;
13010 find->length = r.num_chars;
13011 find->height = r.ymax - r.ymin;
13012 find->prev_first = prev_start;
13016 for (i=0; first+i < n; ++i)
13017 find->x += nk_textedit_get_width(state, first, i, font);
13025 if (NK_TEXT_HAS_SELECTION(state)) {
13039 nk_textedit_makeundo_delete(state, where, len);
13048 nk_textedit_clamp(state);
13049 if (NK_TEXT_HAS_SELECTION(state)) {
13078 if (NK_TEXT_HAS_SELECTION(state)) {
13079 nk_textedit_sortselection(state);
13090 if (NK_TEXT_HAS_SELECTION(state)) {
13091 nk_textedit_sortselection(state);
13092 nk_textedit_clamp(state);
13100 nk_is_word_boundary(
struct nk_text_edit *state,
int idx)
13104 if (idx <= 0)
return 1;
13106 return (c ==
' ' || c ==
'\t' ||c == 0x3000 || c ==
',' || c ==
';' ||
13107 c ==
'(' || c ==
')' || c ==
'{' || c ==
'}' || c ==
'[' || c ==
']' ||
13112 nk_textedit_move_to_word_previous(
struct nk_text_edit *state)
13114 int c = state->
cursor - 1;
13115 while( c >= 0 && !nk_is_word_boundary(state, c))
13125 nk_textedit_move_to_word_next(
struct nk_text_edit *state)
13128 int c = state->
cursor+1;
13129 while( c < len && !nk_is_word_boundary(state, c))
13139 nk_textedit_prep_selection_at_cursor(
struct nk_text_edit *state)
13142 if (!NK_TEXT_HAS_SELECTION(state))
13153 if (NK_TEXT_HAS_SELECTION(state)) {
13166 const char *text = (
const char *) ctext;
13170 nk_textedit_clamp(state);
13176 nk_textedit_makeundo_insert(state, state->
cursor, glyphs);
13199 while ((text_len < total_len) && glyph_len)
13202 if (unicode == 127)
goto next;
13204 if (unicode ==
'\n' && state->
single_line)
goto next;
13206 if (state->
filter && !state->
filter(state, unicode))
goto next;
13208 if (!NK_TEXT_HAS_SELECTION(state) &&
13212 nk_textedit_makeundo_replace(state, state->
cursor, 1, 1);
13226 nk_textedit_makeundo_insert(state, state->
cursor, 1);
13232 text_len += glyph_len;
13233 glyph_len =
nk_utf_decode(text + text_len, &unicode, total_len-text_len);
13285 nk_textedit_clamp(state);
13286 nk_textedit_prep_selection_at_cursor(state);
13295 if (NK_TEXT_HAS_SELECTION(state))
13296 nk_textedit_move_to_first(state);
13297 else if (state->
cursor > 0)
13304 nk_textedit_prep_selection_at_cursor(state);
13307 nk_textedit_clamp(state);
13313 if (NK_TEXT_HAS_SELECTION(state))
13314 nk_textedit_move_to_last(state);
13316 nk_textedit_clamp(state);
13322 if( !NK_TEXT_HAS_SELECTION( state ) )
13323 nk_textedit_prep_selection_at_cursor(state);
13324 state->
cursor = nk_textedit_move_to_word_previous(state);
13326 nk_textedit_clamp(state );
13328 if (NK_TEXT_HAS_SELECTION(state))
13329 nk_textedit_move_to_first(state);
13331 state->
cursor = nk_textedit_move_to_word_previous(state);
13332 nk_textedit_clamp(state );
13338 if( !NK_TEXT_HAS_SELECTION( state ) )
13339 nk_textedit_prep_selection_at_cursor(state);
13340 state->
cursor = nk_textedit_move_to_word_next(state);
13342 nk_textedit_clamp(state);
13344 if (NK_TEXT_HAS_SELECTION(state))
13345 nk_textedit_move_to_last(state);
13347 state->
cursor = nk_textedit_move_to_word_next(state);
13348 nk_textedit_clamp(state );
13353 struct nk_text_find find;
13354 struct nk_text_edit_row row;
13355 int i, sel = shift_mod;
13364 nk_textedit_prep_selection_at_cursor(state);
13365 else if (NK_TEXT_HAS_SELECTION(state))
13366 nk_textedit_move_to_last(state);
13369 nk_textedit_clamp(state);
13378 int start = find.first_char + find.length;
13381 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
13384 for (i=0; i < row.num_chars && x < row.x1; ++i) {
13385 float dx = nk_textedit_get_width(state, start, i, font);
13391 nk_textedit_clamp(state);
13401 struct nk_text_find find;
13402 struct nk_text_edit_row row;
13403 int i, sel = shift_mod;
13412 nk_textedit_prep_selection_at_cursor(state);
13413 else if (NK_TEXT_HAS_SELECTION(state))
13414 nk_textedit_move_to_first(state);
13417 nk_textedit_clamp(state);
13422 if (find.prev_first != find.first_char) {
13427 state->
cursor = find.prev_first;
13428 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
13431 for (i=0; i < row.num_chars && x < row.x1; ++i) {
13432 float dx = nk_textedit_get_width(state, find.prev_first, i, font);
13438 nk_textedit_clamp(state);
13449 if (NK_TEXT_HAS_SELECTION(state))
13462 if (NK_TEXT_HAS_SELECTION(state))
13465 nk_textedit_clamp(state);
13466 if (state->
cursor > 0) {
13476 nk_textedit_prep_selection_at_cursor(state);
13487 nk_textedit_prep_selection_at_cursor(state);
13499 struct nk_text_find find;
13500 nk_textedit_clamp(state);
13501 nk_textedit_prep_selection_at_cursor(state);
13509 struct nk_text_find find;
13512 nk_textedit_clamp(state);
13513 nk_textedit_move_to_first(state);
13516 state->
cursor = find.first_char;
13523 struct nk_text_find find;
13524 nk_textedit_clamp(state);
13525 nk_textedit_prep_selection_at_cursor(state);
13529 state->
cursor = find.first_char + find.length;
13534 struct nk_text_find find;
13535 nk_textedit_clamp(state);
13536 nk_textedit_move_to_first(state);
13541 state->
cursor = find.first_char + find.length;
13615 nk_textedit_flush_redo(state);
13620 nk_textedit_discard_undo(state);
13633 nk_textedit_discard_undo(state);
13639 int insert_len,
int delete_len)
13649 if (insert_len == 0) {
13674 r->
where = u.where;
13676 if (u.delete_length)
13695 nk_textedit_discard_redo(s);
13706 for (i=0; i < u.delete_length; ++i)
13715 if (u.insert_length) {
13718 &s->
undo_char[u.char_storage], u.insert_length);
13721 state->
cursor = (short)(u.where + u.insert_length);
13780 nk_textedit_createundo(&state->
undo, where, 0, length);
13787 nk_rune *p = nk_textedit_createundo(&state->
undo, where, length, 0);
13789 for (i=0; i < length; ++i)
13795 nk_textedit_makeundo_replace(
struct nk_text_edit *state,
int where,
13796 int old_length,
int new_length)
13799 nk_rune *p = nk_textedit_createundo(&state->
undo, where, old_length, new_length);
13801 for (i=0; i < old_length; ++i)
13832 if (!state || !memory || !size)
return;
13843 if (!state || !alloc)
return;
13849 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
13854 if (!state)
return;
13857 nk_str_init_default(&state->
string);
13873 if (!state)
return;
13882 #define nk_widget_state_reset(s)\
13883 if ((*(s)) & NK_WIDGET_STATE_MODIFIED)\
13884 (*(s)) = NK_WIDGET_STATE_INACTIVE|NK_WIDGET_STATE_MODIFIED;\
13885 else (*(s)) = NK_WIDGET_STATE_INACTIVE;
13895 const char *
string,
int len,
const struct nk_text *t,
13903 if (!o || !t)
return;
13905 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
13906 label.x = 0; label.w = 0;
13907 label.y = b.
y + t->padding.y;
13911 text_width += (2.0f * t->padding.x);
13915 label.x = b.
x + t->padding.x;
13916 label.w =
NK_MAX(0, b.
w - 2 * t->padding.x);
13918 label.w =
NK_MAX(1, 2 * t->padding.x + (
float)text_width);
13919 label.x = (b.
x + t->padding.x + ((b.
w - 2 * t->padding.x) - label.w) / 2);
13920 label.x =
NK_MAX(b.
x + t->padding.x, label.x);
13921 label.w =
NK_MIN(b.
x + b.
w, label.x + label.w);
13922 if (label.w >= label.x) label.w -= label.x;
13924 label.x =
NK_MAX(b.
x + t->padding.x, (b.
x + b.
w) - (2 * t->padding.x + (
float)text_width));
13925 label.w = (float)text_width + 2 * t->padding.x;
13930 label.y = b.
y + b.
h/2.0f - (float)f->
height/2.0f;
13937 len, f, t->background, t->text);
13942 const char *
string,
int len,
const struct nk_text *t,
13955 if (!o || !t)
return;
13958 text.background = t->background;
13959 text.text = t->text;
13961 b.
w =
NK_MAX(b.
w, 2 * t->padding.x);
13962 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
13963 b.
h = b.
h - 2 * t->padding.y;
13965 line.x = b.
x + t->padding.x;
13966 line.y = b.
y + t->padding.y;
13967 line.w = b.
w - 2 * t->padding.x;
13968 line.h = 2 * t->padding.y + f->
height;
13970 fitting = nk_text_clamp(f,
string, len, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
13971 while (done < len) {
13972 if (!fitting || line.y + line.h >= (b.
y + b.
h))
break;
13973 nk_widget_text(o, line, &
string[done], fitting, &text,
NK_TEXT_LEFT, f);
13975 line.y += f->
height + 2 * t->padding.y;
13976 fitting = nk_text_clamp(f, &
string[done], len - done, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
14001 text.background = background;
14002 text.text = foreground;
14013 nk_fill_rect(out, nk_shrink_rect(content, border_width), 0, background);
14031 points[2].x, points[2].y, foreground);
14044 nk_widget_state_reset(state);
14053 #ifdef NK_BUTTON_TRIGGER_ON_RELEASE
14069 const struct nk_rect *bounds, nk_flags state,
14074 background = &style->
hover;
14076 background = &style->
active;
14077 else background = &style->
normal;
14097 if (!out || !style)
14116 const struct nk_rect *bounds,
const struct nk_rect *content, nk_flags state,
14118 nk_flags text_alignment,
const struct nk_user_font *font)
14122 background = nk_draw_button(out, bounds, state, style);
14126 text.background = background->
data.
color;
14128 if (state & NK_WIDGET_STATE_HOVER)
14130 else if (state & NK_WIDGET_STATE_ACTIVED)
14135 nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
14139 nk_do_button_text(nk_flags *state,
14153 if (!out || !style || !font || !
string)
14156 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14158 nk_draw_button_text(out, &bounds, &content, *state, style,
string, len, align, font);
14173 background = nk_draw_button(out, bounds, state, style);
14178 if (state & NK_WIDGET_STATE_HOVER)
14180 else if (state & NK_WIDGET_STATE_ACTIVED)
14183 nk_draw_symbol(out, type, *content, bg, sym, 1, font);
14187 nk_do_button_symbol(nk_flags *state,
14200 if (!out || !style || !font || !state)
14203 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14205 nk_draw_button_symbol(out, &bounds, &content, *state, style, symbol, font);
14215 nk_draw_button(out, bounds, state, style);
14220 nk_do_button_image(nk_flags *state,
14231 if (!out || !style || !state)
14234 ret = nk_do_button(state, out, bounds, style, in, b, &content);
14241 nk_draw_button_image(out, &bounds, &content, *state, style, &img);
14258 background = nk_draw_button(out, bounds, state, style);
14260 text.background = background->
data.
color;
14264 if (state & NK_WIDGET_STATE_HOVER) {
14267 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14276 nk_draw_symbol(out, type, *symbol, style->
text_background, sym, 0, font);
14281 nk_do_button_text_symbol(nk_flags *state,
14283 enum nk_symbol_type symbol,
const char *str,
int len, nk_flags align,
14288 struct nk_rect tri = {0,0,0,0};
14294 if (!out || !style || !font)
14297 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14298 tri.
y = content.
y + (content.
h/2) - font->
height/2;
14300 if (align & NK_TEXT_ALIGN_LEFT) {
14301 tri.
x = (content.
x + content.
w) - (2 * style->
padding.
x + tri.
w);
14303 }
else tri.
x = content.
x + 2 * style->
padding.
x;
14307 nk_draw_button_text_symbol(out, &bounds, &content, &tri,
14308 *state, style, str, len, symbol, font);
14317 const char *str,
int len,
const struct nk_user_font *font,
14322 background = nk_draw_button(out, bounds, state, style);
14326 text.background = background->
data.
color;
14328 if (state & NK_WIDGET_STATE_HOVER)
14330 else if (state & NK_WIDGET_STATE_ACTIVED)
14340 nk_do_button_text_image(nk_flags *state,
14342 struct nk_image img,
const char* str,
int len, nk_flags align,
14354 if (!out || !font || !style || !str)
14357 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14359 icon.w = icon.h = bounds.
h - 2 * style->
padding.
y;
14360 if (align & NK_TEXT_ALIGN_LEFT) {
14361 icon.x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.w);
14362 icon.x =
NK_MAX(icon.x, 0);
14363 }
else icon.x = bounds.
x + 2 * style->
padding.
x;
14371 nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img);
14381 enum nk_toggle_type {
14388 nk_flags *state,
int active)
14390 nk_widget_state_reset(state);
14406 const struct nk_rect *cursors,
const char *
string,
int len,
14414 if (state & NK_WIDGET_STATE_HOVER) {
14415 background = &style->
hover;
14418 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14419 background = &style->
hover;
14423 background = &style->
normal;
14439 text.padding.x = 0;
14440 text.padding.y = 0;
14442 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
14449 const struct nk_rect *cursors,
const char *
string,
int len,
14457 if (state & NK_WIDGET_STATE_HOVER) {
14458 background = &style->
hover;
14461 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14462 background = &style->
hover;
14466 background = &style->
normal;
14482 text.padding.x = 0;
14483 text.padding.y = 0;
14485 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
14489 nk_do_toggle(nk_flags *state,
14491 int *active,
const char *str,
int len,
enum nk_toggle_type type,
14504 if (!out || !style || !font || !active)
14518 select.
h = select.
w;
14519 select.
y = r.
y + r.
h/2.0f - select.
h/2.0f;
14529 label.
x = select.
x + select.
w + style->
spacing;
14530 label.
y = select.
y;
14532 label.
h = select.
w;
14535 was_active = *active;
14536 *active = nk_toggle_behavior(in, bounds, state, *active);
14541 if (type == NK_TOGGLE_CHECK) {
14542 nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
14544 nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
14548 return (was_active != *active);
14560 const char *
string,
int len, nk_flags align,
const struct nk_user_font *font)
14564 text.padding = style->
padding;
14568 if (state & NK_WIDGET_STATE_ACTIVED) {
14569 background = &style->
pressed;
14571 }
else if (state & NK_WIDGET_STATE_HOVER) {
14572 background = &style->
hover;
14575 background = &style->
normal;
14579 if (state & NK_WIDGET_STATE_ACTIVED) {
14582 }
else if (state & NK_WIDGET_STATE_HOVER) {
14595 text.background =
nk_rgba(0,0,0,0);
14598 text.background = background->
data.
color;
14601 nk_widget_text(out, *bounds,
string, len, &text, align, font);
14606 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
14621 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
14622 old_value = *
value;
14632 *value = !(*value);
14636 nk_draw_selectable(out, *state, style, *value, &bounds, 0,0, str, len, align, font);
14638 return old_value != *
value;
14643 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
14659 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
14660 old_value = *
value;
14668 *value = !(*value);
14671 icon.
w = icon.
h = bounds.
h - 2 * style->
padding.
y;
14672 if (align & NK_TEXT_ALIGN_LEFT) {
14673 icon.
x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.
w);
14675 }
else icon.
x = bounds.
x + 2 * style->
padding.
x;
14684 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, img, str, len, align, font);
14686 return old_value != *
value;
14696 nk_slider_behavior(nk_flags *state,
struct nk_rect *logical_cursor,
14698 struct nk_rect bounds,
float slider_min,
float slider_max,
float slider_value,
14699 float slider_step,
float slider_steps)
14701 int left_mouse_down;
14702 int left_mouse_click_in_cursor;
14705 nk_widget_state_reset(state);
14710 if (left_mouse_down && left_mouse_click_in_cursor)
14713 const float d = in->
mouse.
pos.
x - (visual_cursor->
x+visual_cursor->
w*0.5f);
14714 const float pxstep = bounds.
w / slider_steps;
14718 if (
NK_ABS(d) >= pxstep) {
14719 const float steps = (float)((
int)(
NK_ABS(d) / pxstep));
14720 slider_value += (d > 0) ? (slider_step*steps) : -(slider_step*steps);
14721 slider_value =
NK_CLAMP(slider_min, slider_value, slider_max);
14722 ratio = (slider_value - slider_min)/slider_step;
14723 logical_cursor->
x = bounds.
x + (logical_cursor->
w * ratio);
14731 if (*state & NK_WIDGET_STATE_HOVER &&
14736 return slider_value;
14742 const struct nk_rect *visual_cursor,
float min,
float value,
float max)
14756 if (state & NK_WIDGET_STATE_ACTIVED) {
14757 background = &style->
active;
14760 }
else if (state & NK_WIDGET_STATE_HOVER) {
14761 background = &style->
hover;
14765 background = &style->
normal;
14772 bar.y = (visual_cursor->
y + visual_cursor->
h/2) - bounds->
h/12;
14774 bar.h = bounds->
h/6;
14777 fill.w = (visual_cursor->
x + (visual_cursor->
w/2.0f)) -
bar.x;
14801 nk_do_slider(nk_flags *state,
14803 float min,
float val,
float max,
float step,
14807 float slider_range;
14810 float slider_value;
14811 float slider_steps;
14812 float cursor_offset;
14814 struct nk_rect visual_cursor;
14815 struct nk_rect logical_cursor;
14819 if (!out || !style)
14834 button.
y = bounds.
y;
14835 button.w = bounds.
h;
14836 button.h = bounds.
h;
14839 button.x = bounds.
x;
14845 button.x = (bounds.
x + bounds.
w) - button.w;
14850 bounds.
x = bounds.
x + button.w + style->
spacing.
x;
14851 bounds.
w = bounds.
w - (2*button.w + 2*style->
spacing.
x);
14859 slider_max =
NK_MAX(min, max);
14860 slider_min =
NK_MIN(min, max);
14861 slider_value =
NK_CLAMP(slider_min, val, slider_max);
14862 slider_range = slider_max - slider_min;
14863 slider_steps = slider_range / step;
14864 cursor_offset = (slider_value - slider_min) / step;
14869 logical_cursor.
h = bounds.
h;
14870 logical_cursor.
w = bounds.
w / slider_steps;
14871 logical_cursor.
x = bounds.
x + (logical_cursor.
w * cursor_offset);
14872 logical_cursor.
y = bounds.
y;
14876 visual_cursor.
y = (bounds.
y + bounds.
h*0.5f) - visual_cursor.
h*0.5f;
14877 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
14879 slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor,
14880 in, bounds, slider_min, slider_max, slider_value, step, slider_steps);
14881 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
14885 nk_draw_slider(out, *state, style, &bounds, &visual_cursor, slider_min, slider_value, slider_max);
14887 return slider_value;
14896 nk_progress_behavior(nk_flags *state,
const struct nk_input *in,
14897 struct nk_rect r, nk_size max, nk_size value,
int modifiable)
14899 nk_widget_state_reset(state);
14905 if (left_mouse_down && left_mouse_click_in_cursor) {
14907 value = (nk_size)
NK_MAX(0,((
float)max * ratio));
14918 if (!max)
return value;
14919 value =
NK_MIN(value, max);
14926 const struct nk_rect *scursor, nk_size value, nk_size max)
14935 if (state & NK_WIDGET_STATE_ACTIVED) {
14936 background = &style->
active;
14938 }
else if (state & NK_WIDGET_STATE_HOVER){
14939 background = &style->
hover;
14942 background = &style->
normal;
14960 nk_do_progress(nk_flags *state,
14962 nk_size value, nk_size max,
int modifiable,
14966 nk_size prog_value;
14971 if (!out || !style)
return 0;
14977 prog_scale = (float)value / (
float)max;
14978 cursor.w = (bounds.
w - 2) * prog_scale;
14981 prog_value =
NK_MIN(value, max);
14982 prog_value = nk_progress_behavior(state, in, bounds, max, prog_value, modifiable);
14986 nk_draw_progress(out, *state, style, &bounds, &cursor, value, max);
14997 nk_scrollbar_behavior(nk_flags *state,
struct nk_input *in,
14998 int has_scrolling,
const struct nk_rect *scroll,
15000 const struct nk_rect *empty1,
float scroll_offset,
15004 int left_mouse_down;
15005 int left_mouse_click_in_cursor;
15006 float scroll_delta;
15008 nk_widget_state_reset(state);
15009 if (!in)
return scroll_offset;
15018 if (left_mouse_down && left_mouse_click_in_cursor) {
15020 float pixel, delta;
15025 delta = (pixel / scroll->
h) * target;
15026 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
h);
15027 cursor_y = scroll->
y + ((scroll_offset/target) * scroll->
h);
15032 delta = (pixel / scroll->
w) * target;
15033 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
w);
15034 cursor_x = scroll->
x + ((scroll_offset/target) * scroll->
w);
15041 scroll_offset =
NK_MAX(0, scroll_offset - scroll->
h);
15042 else scroll_offset =
NK_MAX(0, scroll_offset - scroll->
w);
15047 scroll_offset =
NK_MIN(scroll_offset + scroll->
h, target - scroll->
h);
15048 else scroll_offset =
NK_MIN(scroll_offset + scroll->
w, target - scroll->
w);
15049 }
else if (has_scrolling) {
15050 if ((scroll_delta < 0 || (scroll_delta > 0))) {
15052 scroll_offset = scroll_offset + scroll_step * (-scroll_delta);
15054 scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
h);
15055 else scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
w);
15061 if (o ==
NK_VERTICAL) scroll_offset = target - scroll->
h;
15068 return scroll_offset;
15074 const struct nk_rect *scroll)
15080 if (state & NK_WIDGET_STATE_ACTIVED) {
15081 background = &style->
active;
15083 }
else if (state & NK_WIDGET_STATE_HOVER) {
15084 background = &style->
hover;
15087 background = &style->
normal;
15107 nk_do_scrollbarv(nk_flags *state,
15109 float offset,
float target,
float step,
float button_pixel_inc,
15118 float scroll_offset;
15120 float scroll_ratio;
15125 if (!out || !style)
return 0;
15129 if (target <= scroll.
h)
return 0;
15137 button.
x = scroll.
x;
15138 button.w = scroll.
w;
15139 button.h = scroll.
w;
15141 scroll_h =
NK_MAX(scroll.
h - 2 * button.h,0);
15142 scroll_step =
NK_MIN(step, button_pixel_inc);
15145 button.y = scroll.
y;
15146 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
15148 offset = offset - scroll_step;
15151 button.y = scroll.
y + scroll.
h - button.h;
15152 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
15154 offset = offset + scroll_step;
15156 scroll.
y = scroll.
y + button.h;
15157 scroll.
h = scroll_h;
15161 scroll_step =
NK_MIN(step, scroll.
h);
15162 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
h);
15163 scroll_ratio = scroll.
h / target;
15164 scroll_off = scroll_offset / target;
15168 cursor.y = scroll.
y + (scroll_off * scroll.
h) + style->
border + style->
padding.
y;
15173 empty_north.x = scroll.
x;
15174 empty_north.y = scroll.
y;
15175 empty_north.w = scroll.
w;
15176 empty_north.h =
NK_MAX(cursor.y - scroll.
y, 0);
15178 empty_south.x = scroll.
x;
15179 empty_south.y = cursor.y + cursor.h;
15180 empty_south.w = scroll.
w;
15181 empty_south.h =
NK_MAX((scroll.
y + scroll.
h) - (cursor.y + cursor.h), 0);
15184 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
15185 &empty_north, &empty_south, scroll_offset, target, scroll_step,
NK_VERTICAL);
15186 scroll_off = scroll_offset / target;
15191 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
15193 return scroll_offset;
15197 nk_do_scrollbarh(nk_flags *state,
15199 float offset,
float target,
float step,
float button_pixel_inc,
15208 float scroll_offset;
15210 float scroll_ratio;
15214 if (!out || !style)
return 0;
15218 scroll.
w =
NK_MAX(scroll.
w, 2 * scroll.
h);
15219 if (target <= scroll.
w)
return 0;
15226 button.
y = scroll.
y;
15227 button.w = scroll.
h;
15228 button.h = scroll.
h;
15230 scroll_w = scroll.
w - 2 * button.w;
15231 scroll_step =
NK_MIN(step, button_pixel_inc);
15234 button.x = scroll.
x;
15235 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
15237 offset = offset - scroll_step;
15240 button.x = scroll.
x + scroll.
w - button.w;
15241 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
15243 offset = offset + scroll_step;
15245 scroll.
x = scroll.
x + button.w;
15246 scroll.
w = scroll_w;
15250 scroll_step =
NK_MIN(step, scroll.
w);
15251 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
w);
15252 scroll_ratio = scroll.
w / target;
15253 scroll_off = scroll_offset / target;
15256 cursor.w = (scroll_ratio * scroll.
w) - (2*style->
border + 2*style->
padding.
x);
15257 cursor.x = scroll.
x + (scroll_off * scroll.
w) + style->
border + style->
padding.
x;
15262 empty_west.x = scroll.
x;
15263 empty_west.y = scroll.
y;
15264 empty_west.w = cursor.x - scroll.
x;
15265 empty_west.h = scroll.
h;
15267 empty_east.x = cursor.x + cursor.w;
15268 empty_east.y = scroll.
y;
15269 empty_east.w = (scroll.
x + scroll.
w) - (cursor.x + cursor.w);
15270 empty_east.h = scroll.
h;
15273 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
15274 &empty_west, &empty_east, scroll_offset, target, scroll_step,
NK_HORIZONTAL);
15275 scroll_off = scroll_offset / target;
15276 cursor.x = scroll.
x + (scroll_off * scroll.
w);
15280 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
15282 return scroll_offset;
15297 if (unicode > 128)
return nk_false;
15305 if ((unicode < '0' || unicode >
'9') && unicode !=
'.' && unicode !=
'-')
15314 if ((unicode < '0' || unicode >
'9') && unicode !=
'-')
15323 if ((unicode < '0' || unicode >
'9') &&
15324 (unicode < 'a' || unicode >
'f') &&
15325 (unicode < 'A' || unicode >
'F'))
15334 if (unicode < '0' || unicode >
'7')
15343 if (unicode !=
'0' && unicode !=
'1')
15355 const struct nk_style_edit *style,
float pos_x,
float pos_y,
15356 float x_offset,
const char *text,
int byte_len,
float row_height,
15358 struct nk_color foreground,
int is_selected)
15363 if (!text || !byte_len || !out || !style)
return;
15365 {
int glyph_len = 0;
15366 nk_rune unicode = 0;
15368 float line_width = 0;
15370 const char *line = text;
15371 float line_offset = 0;
15372 int line_count = 0;
15376 txt.background = background;
15377 txt.text = foreground;
15379 glyph_len =
nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
15380 if (!glyph_len)
return;
15381 while ((text_len < byte_len) && glyph_len)
15383 if (unicode ==
'\n') {
15386 label.
y = pos_y + line_offset;
15387 label.
h = row_height;
15388 label.
w = line_width;
15391 label.
x += x_offset;
15395 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
15401 line = text + text_len;
15402 line_offset += row_height;
15403 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)(byte_len-text_len));
15406 if (unicode ==
'\r') {
15408 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
15412 line_width += (float)glyph_width;
15413 text_len += glyph_len;
15414 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
15417 if (line_width > 0) {
15420 label.
y = pos_y + line_offset;
15421 label.
h = row_height;
15422 label.
w = line_width;
15425 label.
x += x_offset;
15429 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
15443 char prev_state = 0;
15444 char is_hovered = 0;
15445 char select_all = 0;
15446 char cursor_follow = 0;
15453 if (!state || !out || !style)
15466 old_clip = out->
clip;
15467 nk_unify(&clip, &old_clip, area.
x, area.y, area.x + area.w, area.y + area.h);
15470 prev_state = (char)edit->
active;
15474 bounds.
x, bounds.
y, bounds.
w, bounds.
h);
15478 if (!prev_state && edit->
active) {
15481 nk_textedit_clear_state(edit, type, filter);
15495 if (prev_state != edit->
active)
15511 nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
15514 nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
15524 int old_mode = edit->
mode;
15528 nk_textedit_key(edit, (
enum nk_keys)i, shift_mod, font, row_height);
15532 if (old_mode != edit->
mode) {
15565 int begin =
NK_MIN(b, e);
15570 if (cut && !(flags & NK_EDIT_READ_ONLY)){
15578 if (paste && (flags & NK_EDIT_CLIPBOARD) && edit->
clip.
paste) {
15594 else nk_widget_state_reset(state);
15605 if (*state & NK_WIDGET_STATE_ACTIVED)
15606 background = &style->
active;
15607 else if (*state & NK_WIDGET_STATE_HOVER)
15608 background = &style->
hover;
15609 else background = &style->
normal;
15620 int total_lines = 1;
15624 const char *cursor_ptr = 0;
15625 const char *select_begin_ptr = 0;
15626 const char *select_end_ptr = 0;
15637 float line_width = 0.0f;
15643 nk_rune unicode = 0;
15653 while ((text_len < len) && glyph_len)
15656 if (!cursor_ptr && glyphs == edit->
cursor)
15661 const char *remaining;
15664 cursor_pos.
y = (float)(total_lines-1) * row_height;
15665 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15666 text_len-row_begin, row_height, &remaining,
15667 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15668 cursor_pos.
x = row_size.x;
15669 cursor_ptr = text + text_len;
15674 glyphs == selection_begin)
15679 const char *remaining;
15682 selection_offset_start.
y = (float)(
NK_MAX(total_lines-1,0)) * row_height;
15683 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15684 text_len-row_begin, row_height, &remaining,
15685 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15686 selection_offset_start.
x = row_size.x;
15687 select_begin_ptr = text + text_len;
15692 glyphs == selection_end)
15697 const char *remaining;
15700 selection_offset_end.
y = (float)(total_lines-1) * row_height;
15701 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15702 text_len-row_begin, row_height, &remaining,
15703 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15704 selection_offset_end.
x = row_size.x;
15705 select_end_ptr = text + text_len;
15707 if (unicode ==
'\n') {
15708 text_size.
x =
NK_MAX(text_size.
x, line_width);
15713 row_begin = text_len;
15714 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
15720 text_len += glyph_len;
15721 line_width += (float)glyph_width;
15723 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
15725 text+text_len, glyph_len);
15728 text_size.
y = (float)total_lines * row_height;
15732 cursor_pos.
x = line_width;
15733 cursor_pos.
y = text_size.
y - row_height;
15743 const float scroll_increment = area.w * 0.25f;
15750 if (flags & NK_EDIT_MULTILINE) {
15760 if (flags & NK_EDIT_MULTILINE)
15764 float scroll_target;
15765 float scroll_offset;
15774 scroll_step = scroll.
h * 0.10f;
15775 scroll_inc = scroll.
h * 0.01f;
15776 scroll_target = text_size.
y;
15777 edit->
scrollbar.
y = nk_do_scrollbarv(&ws, out, scroll, 0,
15778 scroll_offset, scroll_target, scroll_step, scroll_inc,
15784 {
struct nk_color background_color;
15786 struct nk_color sel_background_color;
15789 struct nk_color cursor_text_color;
15794 if (*state & NK_WIDGET_STATE_ACTIVED) {
15795 background = &style->
active;
15801 }
else if (*state & NK_WIDGET_STATE_HOVER) {
15802 background = &style->
hover;
15809 background = &style->
normal;
15817 background_color =
nk_rgba(0,0,0,0);
15818 else background_color = background->
data.
color;
15825 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15826 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
15827 background_color, text_color,
nk_false);
15833 NK_ASSERT(select_begin_ptr);
15834 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15835 area.y - edit->
scrollbar.
y, 0, begin, (
int)(select_begin_ptr - begin),
15836 row_height, font, background_color, text_color,
nk_false);
15840 NK_ASSERT(select_begin_ptr);
15841 if (!select_end_ptr) {
15845 nk_edit_draw_text(out, style,
15847 area.y + selection_offset_start.
y - edit->
scrollbar.
y,
15848 selection_offset_start.
x,
15849 select_begin_ptr, (
int)(select_end_ptr - select_begin_ptr),
15850 row_height, font, sel_background_color, sel_text_color,
nk_true);
15853 selection_end < edit->
string.len))
15856 const char *begin = select_end_ptr;
15859 NK_ASSERT(select_end_ptr);
15860 nk_edit_draw_text(out, style,
15862 area.y + selection_offset_end.
y - edit->
scrollbar.
y,
15863 selection_offset_end.
x,
15864 begin, (
int)(end - begin), row_height, font,
15865 background_color, text_color,
nk_true);
15873 (cursor_ptr && *cursor_ptr ==
'\n')) {
15877 cursor.h = font->
height;
15878 cursor.x = area.x + cursor_pos.
x - edit->
scrollbar.
x;
15879 cursor.y = area.y + cursor_pos.
y + row_height/2.0f - cursor.h/2.0f;
15889 NK_ASSERT(cursor_ptr);
15895 label.
h = row_height;
15898 txt.background = cursor_color;;
15899 txt.text = cursor_text_color;
15901 nk_widget_text(out, label, cursor_ptr, glyph_len, &txt,
NK_TEXT_LEFT, font);
15913 if (*state & NK_WIDGET_STATE_ACTIVED) {
15914 background = &style->
active;
15916 }
else if (*state & NK_WIDGET_STATE_HOVER) {
15917 background = &style->
hover;
15920 background = &style->
normal;
15924 background_color =
nk_rgba(0,0,0,0);
15925 else background_color = background->
data.
color;
15926 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15927 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
15928 background_color, text_color,
nk_false);
15939 enum nk_property_status {
15940 NK_PROPERTY_DEFAULT,
15944 enum nk_property_filter {
15948 enum nk_property_kind {
15953 union nk_property {
15958 struct nk_property_variant {
15959 enum nk_property_kind kind;
15960 union nk_property value;
15961 union nk_property min_value;
15962 union nk_property max_value;
15963 union nk_property step;
15967 nk_drag_behavior(nk_flags *state,
const struct nk_input *in,
15968 struct nk_rect drag,
struct nk_property_variant *variant,
15969 float inc_per_pixel)
15972 int left_mouse_click_in_cursor = in &&
15975 nk_widget_state_reset(state);
15979 if (left_mouse_down && left_mouse_click_in_cursor) {
15980 float delta, pixels;
15982 delta = pixels * inc_per_pixel;
15983 switch (variant->kind) {
15985 case NK_PROPERTY_INT:
15986 variant->value.i = variant->value.i + (
int)delta;
15987 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
15989 case NK_PROPERTY_FLOAT:
15990 variant->value.f = variant->value.f + (float)delta;
15991 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
15993 case NK_PROPERTY_DOUBLE:
15994 variant->value.d = variant->value.d + (double)delta;
15995 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
16007 nk_property_behavior(nk_flags *ws,
const struct nk_input *in,
16009 struct nk_rect empty,
int *state,
struct nk_property_variant *variant,
16010 float inc_per_pixel)
16012 if (in && *state == NK_PROPERTY_DEFAULT) {
16014 *state = NK_PROPERTY_EDIT;
16016 *state = NK_PROPERTY_DRAG;
16018 *state = NK_PROPERTY_DRAG;
16020 if (*state == NK_PROPERTY_DRAG) {
16021 nk_drag_behavior(ws, in, property, variant, inc_per_pixel);
16022 if (!(*ws & NK_WIDGET_STATE_ACTIVED)) *state = NK_PROPERTY_DEFAULT;
16028 const struct nk_rect *bounds,
const struct nk_rect *label, nk_flags state,
16029 const char *name,
int len,
const struct nk_user_font *font)
16035 if (state & NK_WIDGET_STATE_ACTIVED) {
16036 background = &style->
active;
16038 }
else if (state & NK_WIDGET_STATE_HOVER) {
16039 background = &style->
hover;
16042 background = &style->
normal;
16049 text.background =
nk_rgba(0,0,0,0);
16051 text.background = background->
data.
color;
16062 nk_do_property(nk_flags *ws,
16064 const char *name,
struct nk_property_variant *variant,
16065 float inc_per_pixel,
char *buffer,
int *len,
16066 int *state,
int *cursor,
int *select_begin,
int *select_end,
16068 enum nk_property_filter filter,
struct nk_input *in,
16077 int num_len, name_len;
16094 left.y =
property.y + style->
border +
property.h/2.0f - left.h/2;
16099 label.
x = left.x + left.w + style->
padding.
x;
16100 label.
w = (float)size + 2 * style->
padding.
x;
16108 right.x =
property.x +
property.w - (right.w + style->
padding.
x);
16111 if (*state == NK_PROPERTY_EDIT) {
16117 switch (variant->kind) {
16119 case NK_PROPERTY_INT:
16120 nk_itoa(
string, variant->value.i);
16123 case NK_PROPERTY_FLOAT:
16124 nk_dtoa(
string, (
double)variant->value.f);
16127 case NK_PROPERTY_DOUBLE:
16128 nk_dtoa(
string, variant->value.d);
16137 edit.
w = (float)size + 2 * style->
padding.
x;
16138 edit.
w =
NK_MIN(edit.
w, right.x - (label.
x + label.
w));
16139 edit.
x = right.x - (edit.
w + style->
padding.
x);
16140 edit.
y =
property.y + style->
border;
16141 edit.
h =
property.h - (2 * style->
border);
16144 empty.
w = edit.
x - (label.
x + label.
w);
16145 empty.
x = label.
x + label.
w;
16146 empty.
y =
property.y;
16147 empty.
h =
property.h;
16150 old = (*state == NK_PROPERTY_EDIT);
16151 nk_property_behavior(ws, in, property, label, edit, empty, state, variant, inc_per_pixel);
16155 nk_draw_property(out, style, &property, &label, *ws, name, name_len, font);
16159 if (nk_do_button_symbol(ws, out, left, style->
sym_left, behavior, &style->
dec_button, in, font)) {
16160 switch (variant->kind) {
16162 case NK_PROPERTY_INT:
16163 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i - variant->step.i, variant->max_value.i);
break;
16164 case NK_PROPERTY_FLOAT:
16165 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f - variant->step.f, variant->max_value.f);
break;
16166 case NK_PROPERTY_DOUBLE:
16167 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d - variant->step.d, variant->max_value.d);
break;
16171 if (nk_do_button_symbol(ws, out, right, style->
sym_right, behavior, &style->
inc_button, in, font)) {
16172 switch (variant->kind) {
16174 case NK_PROPERTY_INT:
16175 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i + variant->step.i, variant->max_value.i);
break;
16176 case NK_PROPERTY_FLOAT:
16177 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f + variant->step.f, variant->max_value.f);
break;
16178 case NK_PROPERTY_DOUBLE:
16179 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d + variant->step.d, variant->max_value.d);
break;
16182 if (old != NK_PROPERTY_EDIT && (*state == NK_PROPERTY_EDIT)) {
16184 NK_MEMCPY(buffer, dst, (nk_size)*length);
16190 }
else active = (*state == NK_PROPERTY_EDIT);
16194 text_edit->
active = (
unsigned char)active;
16204 nk_do_edit(ws, out, edit,
NK_EDIT_FIELD|NK_EDIT_AUTO_SELECT,
16205 filters[filter], text_edit, &style->
edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
16208 *cursor = text_edit->
cursor;
16214 if (active && !text_edit->
active) {
16216 *state = NK_PROPERTY_DEFAULT;
16217 buffer[*len] =
'\0';
16218 switch (variant->kind) {
16220 case NK_PROPERTY_INT:
16221 variant->value.i =
nk_strtoi(buffer, 0);
16222 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
16224 case NK_PROPERTY_FLOAT:
16226 variant->value.f =
nk_strtof(buffer, 0);
16227 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
16229 case NK_PROPERTY_DOUBLE:
16231 variant->value.d =
nk_strtod(buffer, 0);
16232 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
16243 nk_color_picker_behavior(nk_flags *state,
16249 int value_changed = 0;
16250 int hsv_changed = 0;
16254 NK_ASSERT(hue_bar);
16262 value_changed = hsv_changed = 1;
16268 value_changed = hsv_changed = 1;
16278 nk_widget_state_reset(state);
16283 if (value_changed) {
16284 color->
a = (
nk_byte)(hsva[3] * 255.0f);
16295 return value_changed;
16307 const float crosshair_size = 7.0f;
16315 NK_ASSERT(hue_bar);
16319 for (i = 0; i < 6; ++i) {
16326 {255, 0, 255, 255},
16330 nk_rect(hue_bar->
x, hue_bar->
y + (
float)i * (hue_bar->
h/6.0f) + 0.5f,
16331 hue_bar->
w, (hue_bar->
h/6.0f) + 0.5f), hue_colors[i], hue_colors[i],
16332 hue_colors[i+1], hue_colors[i+1]);
16334 line_y = (float)(
int)(hue_bar->
y + hsva[0] * matrix->
h + 0.5f);
16336 line_y, 1,
nk_rgb(255,255,255));
16341 line_y = (float)(
int)(alpha_bar->
y + (1.0f - alpha) * matrix->
h + 0.5f);
16345 line_y, 1,
nk_rgb(255,255,255));
16349 temp =
nk_hsv_f(hsva[0], 1.0f, 1.0f);
16354 {
struct nk_vec2 p;
float S = hsva[1];
float V = hsva[2];
16355 p.
x = (float)(
int)(matrix->
x + S * matrix->
w);
16356 p.y = (float)(
int)(matrix->
y + (1.0f - V) * matrix->
h);
16357 nk_stroke_line(o, p.x - crosshair_size, p.y, p.x-2, p.y, 1.0f, white);
16358 nk_stroke_line(o, p.x + crosshair_size + 1, p.y, p.x+3, p.y, 1.0f, white);
16359 nk_stroke_line(o, p.x, p.y + crosshair_size + 1, p.x, p.y+3, 1.0f, white);
16360 nk_stroke_line(o, p.x, p.y - crosshair_size, p.x, p.y-2, 1.0f, white);}
16364 nk_do_color_picker(nk_flags *state,
16380 if (!out || !color || !state || !font)
16384 bounds.
x += padding.
x;
16385 bounds.
y += padding.
x;
16386 bounds.
w -= 2 * padding.
x;
16387 bounds.
h -= 2 * padding.
y;
16389 matrix.
x = bounds.
x;
16390 matrix.
y = bounds.
y;
16391 matrix.
h = bounds.
h;
16392 matrix.
w = bounds.
w - (3 * padding.
x + 2 * bar_w);
16395 hue_bar.
y = bounds.
y;
16396 hue_bar.
h = matrix.
h;
16397 hue_bar.
x = matrix.
x + matrix.
w + padding.
x;
16399 alpha_bar.
x = hue_bar.
x + hue_bar.
w + padding.
x;
16400 alpha_bar.
y = bounds.
y;
16401 alpha_bar.
w = bar_w;
16402 alpha_bar.
h = matrix.
h;
16404 ret = nk_color_picker_behavior(state, &bounds, &matrix, &hue_bar,
16405 (fmt ==
NK_RGBA) ? &alpha_bar:0, color, in);
16406 nk_draw_color_picker(out, &matrix, &hue_bar, (fmt ==
NK_RGBA) ? &alpha_bar:0, *color);
16416 #define NK_COLOR_MAP(NK_COLOR)\
16417 NK_COLOR(NK_COLOR_TEXT, 175,175,175,255) \
16418 NK_COLOR(NK_COLOR_WINDOW, 45, 45, 45, 255) \
16419 NK_COLOR(NK_COLOR_HEADER, 40, 40, 40, 255) \
16420 NK_COLOR(NK_COLOR_BORDER, 65, 65, 65, 255) \
16421 NK_COLOR(NK_COLOR_BUTTON, 50, 50, 50, 255) \
16422 NK_COLOR(NK_COLOR_BUTTON_HOVER, 40, 40, 40, 255) \
16423 NK_COLOR(NK_COLOR_BUTTON_ACTIVE, 35, 35, 35, 255) \
16424 NK_COLOR(NK_COLOR_TOGGLE, 100,100,100,255) \
16425 NK_COLOR(NK_COLOR_TOGGLE_HOVER, 120,120,120,255) \
16426 NK_COLOR(NK_COLOR_TOGGLE_CURSOR, 45, 45, 45, 255) \
16427 NK_COLOR(NK_COLOR_SELECT, 45, 45, 45, 255) \
16428 NK_COLOR(NK_COLOR_SELECT_ACTIVE, 35, 35, 35,255) \
16429 NK_COLOR(NK_COLOR_SLIDER, 38, 38, 38, 255) \
16430 NK_COLOR(NK_COLOR_SLIDER_CURSOR, 100,100,100,255) \
16431 NK_COLOR(NK_COLOR_SLIDER_CURSOR_HOVER, 120,120,120,255) \
16432 NK_COLOR(NK_COLOR_SLIDER_CURSOR_ACTIVE, 150,150,150,255) \
16433 NK_COLOR(NK_COLOR_PROPERTY, 38, 38, 38, 255) \
16434 NK_COLOR(NK_COLOR_EDIT, 38, 38, 38, 255) \
16435 NK_COLOR(NK_COLOR_EDIT_CURSOR, 175,175,175,255) \
16436 NK_COLOR(NK_COLOR_COMBO, 45, 45, 45, 255) \
16437 NK_COLOR(NK_COLOR_CHART, 120,120,120,255) \
16438 NK_COLOR(NK_COLOR_CHART_COLOR, 45, 45, 45, 255) \
16439 NK_COLOR(NK_COLOR_CHART_COLOR_HIGHLIGHT,255, 0, 0, 255) \
16440 NK_COLOR(NK_COLOR_SCROLLBAR, 40, 40, 40, 255) \
16441 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR, 100,100,100,255) \
16442 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_HOVER,120,120,120,255) \
16443 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,150,150,150,255) \
16444 NK_COLOR(NK_COLOR_TAB_HEADER, 40, 40, 40,255)
16448 #define NK_COLOR(a,b,c,d,e) {b,c,d,e},
16449 NK_COLOR_MAP(NK_COLOR)
16454 #define NK_COLOR(a,b,c,d,e) #a,
16455 NK_COLOR_MAP(NK_COLOR)
16460 {
return nk_color_names[c];}
16491 style = &ctx->
style;
16492 table = (!table) ? nk_default_color_style: table;
16495 text = &style->
text;
16500 button = &style->
button;
16580 toggle = &style->
option;
16621 slider = &style->
slider;
16732 edit = &style->
edit;
16770 property->padding =
nk_vec2(4,4);
16771 property->border = 1;
16772 property->rounding = 10;
16773 property->draw_begin = 0;
16774 property->draw_end = 0;
16821 chart = &style->
chart;
16832 combo = &style->
combo;
17022 style = &ctx->
style;
17032 struct nk_config_stack_user_font *font_stack;
17033 struct nk_config_stack_user_font_element *element;
17036 if (!ctx)
return 0;
17039 NK_ASSERT(font_stack->head < (
int)
NK_LEN(font_stack->elements));
17040 if (font_stack->head >= (
int)
NK_LEN(font_stack->elements))
17043 element = &font_stack->elements[font_stack->head++];
17053 struct nk_config_stack_user_font *font_stack;
17054 struct nk_config_stack_user_font_element *element;
17057 if (!ctx)
return 0;
17060 NK_ASSERT(font_stack->head > 0);
17061 if (font_stack->head < 1)
17064 element = &font_stack->elements[--font_stack->head];
17065 *element->address = element->old_value;
17069 #define NK_STYLE_PUSH_IMPLEMENATION(prefix, type, stack) \
17070 nk_style_push_##type(struct nk_context *ctx, prefix##_##type *address, prefix##_##type value)\
17072 struct nk_config_stack_##type * type_stack;\
17073 struct nk_config_stack_##type##_element *element;\
17075 if (!ctx) return 0;\
17076 type_stack = &ctx->stacks.stack;\
17077 NK_ASSERT(type_stack->head < (int)NK_LEN(type_stack->elements));\
17078 if (type_stack->head >= (int)NK_LEN(type_stack->elements))\
17080 element = &type_stack->elements[type_stack->head++];\
17081 element->address = address;\
17082 element->old_value = *address;\
17087 #define NK_STYLE_POP_IMPLEMENATION(type, stack) \
17088 nk_style_pop_##type(struct nk_context *ctx)\
17090 struct nk_config_stack_##type *type_stack;\
17091 struct nk_config_stack_##type##_element *element;\
17093 if (!ctx) return 0;\
17094 type_stack = &ctx->stacks.stack;\
17095 NK_ASSERT(type_stack->head > 0);\
17096 if (type_stack->head < 1)\
17098 element = &type_stack->elements[--type_stack->head];\
17099 *element->address = element->old_value;\
17103 NK_API int NK_STYLE_PUSH_IMPLEMENATION(
struct nk, style_item, style_items)
17104 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,
float, floats)
17105 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk, vec2, vectors)
17106 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,flags, flags)
17107 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk,color, colors)
17109 NK_API int NK_STYLE_POP_IMPLEMENATION(style_item, style_items)
17110 NK_API int NK_STYLE_POP_IMPLEMENATION(
float,floats)
17111 NK_API int NK_STYLE_POP_IMPLEMENATION(vec2, vectors)
17112 NK_API int NK_STYLE_POP_IMPLEMENATION(flags,flags)
17113 NK_API int NK_STYLE_POP_IMPLEMENATION(color,colors)
17120 if (!ctx)
return 0;
17121 style = &ctx->style;
17148 style = &ctx->
style;
17159 style = &ctx->
style;
17161 style->
cursors[i] = &cursors[i];
17172 unsigned int capacity)
17174 nk_zero(pool,
sizeof(*pool));
17175 pool->
alloc = *alloc;
17182 nk_pool_free(
struct nk_pool *pool)
17195 nk_pool_init_fixed(
struct nk_pool *pool,
void *memory, nk_size size)
17197 nk_zero(pool,
sizeof(*pool));
17198 NK_ASSERT(size >=
sizeof(
struct nk_page));
17199 if (size <
sizeof(
struct nk_page))
return;
17207 nk_pool_alloc(
struct nk_pool *pool)
17213 if (!pool->
pages) {
17214 NK_ASSERT(pool->
pages);
17220 nk_size size =
sizeof(
struct nk_page);
17221 size += NK_POOL_DEFAULT_CAPACITY *
sizeof(
union nk_page_data);
17223 page->next = pool->
pages;
17224 pool->
pages = page;
17253 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
17254 nk_draw_list_init(&ctx->draw_list);
17258 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
17264 alloc.
alloc = nk_malloc;
17265 alloc.
free = nk_mfree;
17266 return nk_init(ctx, &alloc, font);
17275 if (!memory)
return 0;
17276 nk_setup(ctx, font);
17288 if (!cmds || !pool)
return 0;
17290 nk_setup(ctx, font);
17298 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
17309 if (!alloc)
return 0;
17310 nk_setup(ctx, font);
17312 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
17317 #ifdef NK_INCLUDE_COMMAND_USERDATA
17319 nk_set_user_data(
struct nk_context *ctx, nk_handle handle)
17322 ctx->userdata = handle;
17335 nk_pool_free(&ctx->
pool);
17368 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
17369 nk_draw_list_clear(&ctx->draw_list);
17389 nk_free_window(ctx, iter->
popup.
win);
17396 if (it->
seq != ctx->
seq) {
17397 nk_remove_table(iter, it);
17399 nk_free_table(ctx, it);
17408 nk_remove_window(ctx, iter);
17409 nk_free_window(ctx, iter);
17411 }
else iter = iter->
next;
17426 if (!ctx || !buffer)
return;
17430 buffer->
clip = nk_null_rect;
17438 nk_start_buffer(ctx, &win->
buffer);
17447 if (!ctx || !win)
return;
17464 if (!ctx || !win)
return;
17476 if (!ctx || !buffer)
return;
17489 if (!ctx || !win)
return;
17490 nk_finish_buffer(ctx, &win->
buffer);
17496 parent_last->
next = buf->
end;
17504 nk_byte *buffer = 0;
17513 nk_start_buffer(ctx, &ctx->
overlay);
17517 mouse_bounds.w = cursor->size.x;
17518 mouse_bounds.h = cursor->size.y;
17521 nk_finish_buffer(ctx, &ctx->
overlay);
17526 while (iter != 0) {
17542 while (iter != 0) {
17568 if (!ctx)
return 0;
17569 if (!ctx->
count)
return 0;
17579 if (!iter)
return 0;
17589 if (!ctx || !cmd || !ctx->
count)
return 0;
17602 nk_panel_has_header(nk_flags flags,
const char *title)
17627 nk_panel_get_border(
const struct nk_style *style, nk_flags flags,
17653 case NK_PANEL_MENU:
return style->window.menu_border_color;
17680 struct nk_vec2 scrollbar_size;
17681 struct nk_vec2 panel_padding;
17694 style = &ctx->
style;
17695 font = style->
font;
17705 panel_padding = nk_panel_get_padding(style, panel_type);
17709 int left_mouse_down;
17710 int left_mouse_click_in_cursor;
17717 if (nk_panel_has_header(win->
flags, title)) {
17720 }
else header.h = panel_padding.y;
17726 if (left_mouse_down && left_mouse_click_in_cursor) {
17736 layout->
type = panel_type;
17739 layout->
bounds.
x += panel_padding.x;
17740 layout->
bounds.
w -= 2*panel_padding.x;
17741 if (win->
flags & NK_WINDOW_BORDER) {
17742 layout->
border = nk_panel_get_border(style, win->
flags, panel_type);
17744 }
else layout->
border = 0;
17759 layout->
bounds.
w -= scrollbar_size.x;
17760 if (!nk_panel_is_nonblock(panel_type)) {
17768 if (nk_panel_has_header(win->
flags, title))
17783 layout->
bounds.
y += header.h;
17784 layout->
bounds.
h -= header.h;
17785 layout->
at_y += header.h;
17788 if (ctx->
active == win) {
17802 text.background =
nk_rgba(0,0,0,0);
17805 text.background = background->
data.
color;
17813 button.w = button.h;
17824 if (nk_do_button_symbol(&ws, &win->
buffer, button,
17837 button.x = (header.w + header.x) - button.w;
17844 button.x = header.x;
17857 struct nk_rect label = {0,0,0,0};
17866 label.
w =
NK_CLAMP(0, label.
w, header.x + header.w - label.
x);
17867 nk_widget_text(out, label,(
const char*)title, text_len, &text,
NK_TEXT_LEFT, font);}
17888 layout->
clip = clip;}
17901 struct nk_vec2 scrollbar_size;
17902 struct nk_vec2 panel_padding;
17911 layout = window->
layout;
17912 style = &ctx->
style;
17915 if (!nk_panel_is_sub(layout->
type))
17920 panel_padding = nk_panel_get_padding(style, layout->
type);
17934 empty_space.x = window->
bounds.
x;
17935 empty_space.y = layout->
bounds.
y;
17936 empty_space.h = panel_padding.y;
17937 empty_space.w = window->
bounds.
w;
17941 empty_space.x = window->
bounds.
x;
17942 empty_space.y = layout->
bounds.
y;
17943 empty_space.w = panel_padding.x + layout->
border;
17944 empty_space.h = layout->
bounds.
h;
17949 empty_space.y = layout->
bounds.
y;
17950 empty_space.w = panel_padding.x + layout->
border;
17951 empty_space.h = layout->
bounds.
h;
17953 empty_space.w += scrollbar_size.x;
17958 empty_space.x = window->
bounds.
x;
17960 empty_space.w = window->
bounds.
w;
17961 empty_space.h = scrollbar_size.y;
17972 int scroll_has_scrolling;
17973 float scroll_target;
17974 float scroll_offset;
17979 if (nk_panel_is_sub(layout->
type))
17982 struct nk_window *root_window = window;
17984 while (root_panel->
parent)
17985 root_panel = root_panel->
parent;
17986 while (root_window->
parent)
17987 root_window = root_window->
parent;
17990 scroll_has_scrolling = 0;
17998 root_panel = window->
layout;
17999 while (root_panel->
parent) {
18001 root_panel = root_panel->
parent;
18004 scroll_has_scrolling =
nk_true;
18007 }
else if (!nk_panel_is_sub(layout->
type)) {
18013 }
else scroll_has_scrolling =
nk_false;
18017 nk_flags state = 0;
18018 scroll.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
18020 scroll.w = scrollbar_size.x;
18023 scroll_offset = (float)*layout->
offset_y;
18024 scroll_step = scroll.h * 0.10f;
18025 scroll_inc = scroll.h * 0.01f;
18026 scroll_target = (
float)(
int)(layout->
at_y - scroll.y);
18027 scroll_offset = nk_do_scrollbarv(&state, out, scroll, scroll_has_scrolling,
18028 scroll_offset, scroll_target, scroll_step, scroll_inc,
18031 if (in && scroll_has_scrolling)
18036 nk_flags state = 0;
18040 scroll.h = scrollbar_size.y;
18042 scroll_offset = (float)*layout->
offset_x;
18043 scroll_target = (
float)(
int)(layout->
max_x - scroll.x);
18044 scroll_step = layout->
max_x * 0.05f;
18045 scroll_inc = layout->
max_x * 0.005f;
18046 scroll_offset = nk_do_scrollbarh(&state, out, scroll, scroll_has_scrolling,
18047 scroll_offset, scroll_target, scroll_step, scroll_inc,
18058 if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
18064 if (layout->
flags & NK_WINDOW_BORDER)
18066 struct nk_color border_color = nk_panel_get_border_color(style, layout->
type);
18076 layout->
border, border_color);
18085 padding_y, layout->
border, border_color);
18090 padding_y, layout->
border, border_color);
18098 scaler.
w = scrollbar_size.x;
18099 scaler.h = scrollbar_size.y;
18102 scaler.x = layout->
bounds.
x - panel_padding.x * 0.5f;
18103 else scaler.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
18105 scaler.x -= scaler.w;
18114 scaler.y + scaler.h, scaler.x + scaler.w,
18115 scaler.y + scaler.h, item->
data.
color);
18118 scaler.y + scaler.h, scaler.x, scaler.y + scaler.h, item->
data.
color);
18129 if (left_mouse_down && left_mouse_click_in_scaler) {
18132 delta_x = -delta_x;
18136 if (window->
bounds.
w + delta_x >= window_size.
x) {
18137 if ((delta_x < 0) || (delta_x > 0 && in->
mouse.
pos.
x >= scaler.x)) {
18157 if (!nk_panel_is_sub(layout->
type)) {
18160 nk_command_buffer_reset(&window->
buffer);
18162 else nk_finish(ctx, window);
18184 nk_zero(&window->
edit,
sizeof(window->
edit));
18210 nk_create_page_element(
struct nk_context *ctx)
18219 elem = nk_pool_alloc(&ctx->
pool);
18221 if (!elem)
return 0;
18228 if (!elem)
return 0;
18237 nk_link_page_element_into_freelist(
struct nk_context *ctx,
18254 nk_link_page_element_into_freelist(ctx, elem);
18258 {
void *elem_end = (
void*)(elem + 1);
18260 if (elem_end == buffer_end)
18262 else nk_link_page_element_into_freelist(ctx, elem);}
18274 elem = nk_create_page_element(ctx);
18275 if (!elem)
return 0;
18285 nk_free_page_element(ctx, pe);
18297 elem = nk_create_page_element(ctx);
18298 if (!elem)
return 0;
18308 nk_free_page_element(ctx, pe);
18345 nk_hash name, nk_uint value)
18349 if (!win || !ctx)
return 0;
18351 struct nk_table *tbl = nk_create_table(ctx);
18353 if (!tbl)
return 0;
18354 nk_push_table(win, tbl);
18363 nk_find_value(
struct nk_window *win, nk_hash name)
18367 unsigned int i = 0;
18368 unsigned int size = iter->
size;
18369 for (i = 0; i <
size; ++i) {
18370 if (iter->
keys[i] == name) {
18372 return &iter->
values[i];
18389 elem = nk_create_page_element(ctx);
18390 if (!elem)
return 0;
18401 nk_free_window(ctx, win->
popup.
win);
18410 nk_remove_table(win, it);
18411 nk_free_table(ctx, it);
18420 nk_free_page_element(ctx, pe);}
18424 nk_find_window(
struct nk_context *ctx, nk_hash hash,
const char *name)
18429 NK_ASSERT(iter != iter->
next);
18430 if (iter->
name == hash) {
18440 enum nk_window_insert_location {
18446 enum nk_window_insert_location loc)
18451 if (!win || !ctx)
return;
18455 NK_ASSERT(iter != iter->
next);
18456 NK_ASSERT(iter != win);
18457 if (iter == win)
return;
18469 if (loc == NK_INSERT_BACK) {
18492 if (win == ctx->
begin || win == ctx->
end) {
18493 if (win == ctx->
begin) {
18498 if (win == ctx->
end) {
18521 struct nk_rect bounds, nk_flags flags)
18528 struct nk_rect bounds, nk_flags flags)
18532 nk_hash title_hash;
18540 NK_ASSERT(!ctx->
current &&
"if this triggers you missed a `nk_end` call");
18541 if (!ctx || ctx->
current || !title || !name)
18545 style = &ctx->
style;
18548 win = nk_find_window(ctx, title_hash, name);
18552 win = (
struct nk_window*)nk_create_window(ctx);
18554 if (!win)
return 0;
18557 nk_insert_window(ctx, win, NK_INSERT_FRONT);
18558 else nk_insert_window(ctx, win, NK_INSERT_BACK);
18563 win->
name = title_hash;
18583 NK_ASSERT(win->
seq != ctx->
seq);
18597 int inpanel, ishovered;
18605 nk_start(ctx, win);
18615 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
18629 if (iter && inpanel && (win != ctx->
end)) {
18636 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
18651 if (!(iter->
flags & NK_WINDOW_BACKGROUND)) {
18654 nk_remove_window(ctx, iter);
18655 nk_insert_window(ctx, iter, NK_INSERT_BACK);
18658 if (!iter && ctx->
end != win) {
18659 if (!(win->
flags & NK_WINDOW_BACKGROUND)) {
18662 nk_remove_window(ctx, win);
18663 nk_insert_window(ctx, win, NK_INSERT_BACK);
18668 if (ctx->
end != win && !(win->
flags & NK_WINDOW_BACKGROUND))
18686 NK_ASSERT(ctx->
current &&
"if this triggers you forgot to call `nk_begin`");
18732 if (!ctx || !ctx->
current)
return 0;
18741 if (!ctx || !ctx->
current)
return 0;
18791 if (!ctx || !ctx->
current)
return 0;
18800 if (!ctx || !ctx->
current)
return 0;
18810 if (!ctx || !ctx->
current)
return 0;
18819 if (!ctx || !ctx->
current)
return 0;
18830 if (!ctx)
return 0;
18858 return any_hovered || any_active;
18865 nk_hash title_hash;
18868 if (!ctx)
return 0;
18872 win = nk_find_window(ctx, title_hash, name);
18873 if (!win)
return 0;
18881 nk_hash title_hash;
18884 if (!ctx)
return 1;
18888 win = nk_find_window(ctx, title_hash, name);
18889 if (!win)
return 1;
18897 nk_hash title_hash;
18900 if (!ctx)
return 1;
18904 win = nk_find_window(ctx, title_hash, name);
18905 if (!win)
return 1;
18913 nk_hash title_hash;
18916 if (!ctx)
return 0;
18920 win = nk_find_window(ctx, title_hash, name);
18921 if (!win)
return 0;
18922 return win == ctx->
active;
18929 nk_hash title_hash;
18932 return nk_find_window(ctx, title_hash, name);
18943 NK_ASSERT(ctx->
current != win &&
"You cannot close a currently active window");
18944 if (ctx->
current == win)
return;
18952 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18953 if (!ctx || !ctx->
current)
return;
18960 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18961 if (!ctx || !ctx->
current)
return;
18969 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18970 if (!ctx || !ctx->
current)
return;
18980 nk_hash title_hash;
18987 win = nk_find_window(ctx, title_hash, name);
18999 if (!ctx || !cond)
return;
19007 nk_hash title_hash;
19014 win = nk_find_window(ctx, title_hash, name);
19026 if (!ctx || !cond)
return;
19034 nk_hash title_hash;
19041 win = nk_find_window(ctx, title_hash, name);
19042 if (win && ctx->
end != win) {
19043 nk_remove_window(ctx, win);
19044 nk_insert_window(ctx, win, NK_INSERT_BACK);
19166 float total_space,
int columns)
19168 float panel_padding;
19169 float panel_spacing;
19176 padding = nk_panel_get_padding(style, type);
19179 panel_padding = 2 * padding.
x;
19180 panel_spacing = (float)
NK_MAX(columns - 1, 0) * spacing.x;
19181 panel_space = total_space - panel_padding - panel_spacing;
19182 return panel_space;
19187 float height,
int cols)
19204 style = &ctx->
style;
19222 if (height == 0.0f)
19224 else layout->
row.
height = height + item_spacing.y;
19230 background.x = win->
bounds.
x;
19231 background.w = win->
bounds.
w;
19232 background.y = layout->
at_y - 1.0f;
19233 background.h = layout->
row.
height + 1.0f;
19240 float height,
int cols,
int width)
19251 nk_panel_layout(ctx, win, height, cols);
19267 NK_ASSERT(pixel_width);
19287 float row_height,
int cols)
19300 nk_panel_layout(ctx, win, row_height, cols);
19331 float ratio = ratio_or_width;
19332 if ((ratio + layout->
row.
filled) > 1.0f)
return;
19362 float height,
int cols,
const float *ratio)
19377 nk_panel_layout(ctx, win, height, cols);
19382 for (i = 0; i < cols; ++i) {
19383 if (ratio[i] < 0.0f)
19385 else r += ratio[i];
19389 layout->
row.
item_width = (r > 0 && n_undef > 0) ? (r / (
float)n_undef):0;
19414 nk_panel_layout(ctx, win, height, 1);
19498 int variable_count = 0;
19499 int min_variable_count = 0;
19500 float min_fixed_width = 0.0f;
19501 float total_fixed_width = 0.0f;
19502 float max_variable_width = 0.0f;
19516 if (width >= 0.0f) {
19517 total_fixed_width += width;
19518 min_fixed_width += width;
19519 }
else if (width < -1.0f) {
19521 total_fixed_width += width;
19522 max_variable_width =
NK_MAX(max_variable_width, width);
19525 min_variable_count++;
19529 if (variable_count) {
19530 float space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
19532 float var_width = (
NK_MAX(space-min_fixed_width,0.0f)) / (
float)variable_count;
19533 int enough_space = var_width >= max_variable_width;
19535 var_width = (
NK_MAX(space-total_fixed_width,0)) / (
float)min_variable_count;
19538 *width = (*width >= 0.0f)? *width: (*width < -1.0f && !enough_space)? -(*width): var_width;
19545 float height,
int widget_count)
19558 nk_panel_layout(ctx, win, height, widget_count);
19619 ret.x = layout->
clip.
x;
19620 ret.y = layout->
clip.
y;
19621 ret.w = layout->
clip.
w;
19639 ret.x = layout->
at_x;
19640 ret.y = layout->
at_y;
19653 NK_ASSERT(ctx->current);
19654 NK_ASSERT(ctx->current->layout);
19655 win = ctx->current;
19670 NK_ASSERT(ctx->current);
19671 NK_ASSERT(ctx->current->layout);
19672 win = ctx->current;
19687 NK_ASSERT(ctx->current);
19688 NK_ASSERT(ctx->current->layout);
19689 win = ctx->current;
19704 NK_ASSERT(ctx->current);
19705 NK_ASSERT(ctx->current->layout);
19706 win = ctx->current;
19719 const float row_height = layout->
row.
height - spacing.
y;
19720 nk_panel_layout(ctx, win, row_height, layout->
row.
columns);
19733 float item_offset = 0;
19734 float item_width = 0;
19735 float item_spacing = 0;
19736 float panel_space = 0;
19746 style = &ctx->
style;
19750 padding = nk_panel_get_padding(style, layout->
type);
19751 panel_space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
19759 item_offset = (
float)layout->
row.
index * item_width;
19760 item_spacing = (float)layout->
row.
index * spacing.x;
19791 item_spacing = (
float)layout->
row.
index * spacing.x;
19792 item_width = (ratio * panel_space);
19803 item_offset = (float)layout->
row.
index * item_width;
19804 item_spacing = (
float)layout->
row.
index * spacing.x;
19810 item_spacing = (float)layout->
row.
index * spacing.x;
19817 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
19818 layout->
max_x = (bounds->
x + bounds->
w);
19827 item_spacing = (float)layout->
row.
index * spacing.x;
19838 item_spacing = (float)layout->
row.
index * spacing.x;
19841 default: NK_ASSERT(0);
break;
19845 bounds->
w = item_width;
19848 bounds->
x = layout->
at_x + item_offset + item_spacing + padding.
x;
19849 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
19850 layout->
max_x = bounds->
x + bounds->
w;
19870 nk_panel_alloc_row(ctx, win);
19873 nk_layout_widget_space(bounds, ctx, win,
nk_true);
19899 nk_layout_widget_space(bounds, ctx, win,
nk_false);
19918 struct nk_rect header = {0,0,0,0};
19919 struct nk_rect sym = {0,0,0,0};
19935 style = &ctx->
style;
19944 widget_state =
nk_widget(&header, ctx);
19949 text.background =
nk_rgba(0,0,0,0);
19951 text.background = background->
data.
color;
19982 button, 0, style->
font);
19986 sym.
x = sym.
x + sym.
w + 4 * item_spacing.x;
19993 header.
w =
NK_MAX(header.
w, sym.
w + item_spacing.x);
19994 label.
x = sym.
x + sym.
w + item_spacing.x;
19996 label.
w = header.
w - (sym.
w + item_spacing.y + style->
tab.
indent);
20000 nk_widget_text(out, label, title,
nk_strlen(title), &text,
20016 const char *hash,
int len,
int line)
20020 nk_hash tree_hash = 0;
20021 nk_uint *state = 0;
20026 tree_hash =
nk_murmur_hash(title, (
int)title_len, (nk_hash)line);
20028 state = nk_find_value(win, tree_hash);
20030 state = nk_add_value(ctx, win, tree_hash, 0);
20031 *state = initial_state;
20039 {
return nk_tree_state_base(ctx, type, 0, title, state);}
20044 {
return nk_tree_state_base(ctx, type, &img, title, state);}
20069 const char *hash,
int len,
int line)
20070 {
return nk_tree_base(ctx, type, 0, title, initial_state, hash, len, line);}
20075 const char *hash,
int len,
int seed)
20076 {
return nk_tree_base(ctx, type, &img, title, initial_state, hash, len, seed);}
20095 nk_layout_peek(&bounds, ctx);
20108 nk_layout_peek(&bounds, ctx);
20121 nk_layout_peek(&bounds, ctx);
20134 nk_layout_peek(&bounds, ctx);
20147 nk_layout_peek(&bounds, ctx);
20162 c.
x = (float)((
int)c.x);
20163 c.y = (float)((
int)c.y);
20164 c.w = (float)((
int)c.w);
20165 c.h = (float)((
int)c.h);
20167 nk_layout_peek(&bounds, ctx);
20168 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
20169 if (!
NK_INTERSECT(c.x, c.y, c.w, c.h, bounds.
x, bounds.
y, bounds.
w, bounds.
h))
20185 c.
x = (float)((
int)c.x);
20186 c.y = (float)((
int)c.y);
20187 c.w = (float)((
int)c.w);
20188 c.h = (float)((
int)c.h);
20190 nk_layout_peek(&bounds, ctx);
20191 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
20192 if (!
NK_INTERSECT(c.x, c.y, c.w, c.h, bounds.
x, bounds.
y, bounds.
w, bounds.
h))
20208 c.
x = (float)((
int)c.x);
20209 c.y = (float)((
int)c.y);
20210 c.w = (float)((
int)c.w);
20211 c.h = (float)((
int)c.h);
20213 nk_layout_peek(&bounds, ctx);
20214 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
20215 if (!
NK_INTERSECT(c.x, c.y, c.w, c.h, bounds.
x, bounds.
y, bounds.
w, bounds.
h))
20235 nk_panel_alloc_space(bounds, ctx);
20251 bounds->
x = (float)((
int)bounds->
x);
20252 bounds->
y = (float)((
int)bounds->
y);
20253 bounds->
w = (float)((
int)bounds->
w);
20254 bounds->
h = (float)((
int)bounds->
h);
20256 c.x = (float)((
int)c.x);
20257 c.y = (float)((
int)c.y);
20258 c.w = (float)((
int)c.w);
20259 c.h = (float)((
int)c.h);
20261 nk_unify(&v, &c, bounds->
x, bounds->
y, bounds->
x + bounds->
w, bounds->
y + bounds->
h);
20262 if (!
NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->
x, bounds->
y, bounds->
w, bounds->
h))
20278 struct nk_vec2 panel_padding;
20287 style = &ctx->
style;
20291 panel_padding = nk_panel_get_padding(style, layout->
type);
20293 bounds->
w += panel_padding.x;
20294 bounds->
x -= panel_padding.x;
20295 }
else bounds->
x -= item_padding.
x;
20298 bounds->
w += panel_padding.x;
20299 else bounds->
w += item_padding.
x;
20314 int i, index, rows;
20328 for (i = 0; i < rows; ++i)
20329 nk_panel_alloc_row(ctx, win);
20335 for (i = 0; i < cols; ++i)
20336 nk_panel_alloc_space(&none, ctx);
20348 nk_flags alignment,
struct nk_color color)
20363 style = &ctx->
style;
20364 nk_panel_alloc_space(&bounds, ctx);
20371 nk_widget_text(&win->
buffer, bounds, str, len, &text, alignment, style->
font);
20391 style = &ctx->
style;
20392 nk_panel_alloc_space(&bounds, ctx);
20399 nk_widget_text_wrap(&win->
buffer, bounds, str, len, &text, style->
font);
20402 #ifdef NK_INCLUDE_STANDARD_VARARGS
20404 nk_labelf_colored(
struct nk_context *ctx, nk_flags flags,
20405 struct nk_color color,
const char *fmt, ...)
20409 va_start(args, fmt);
20410 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20417 const char *fmt, ...)
20421 va_start(args, fmt);
20422 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20428 nk_labelf(
struct nk_context *ctx, nk_flags flags,
const char *fmt, ...)
20432 va_start(args, fmt);
20433 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20439 nk_labelf_wrap(
struct nk_context *ctx,
const char *fmt,...)
20443 va_start(args, fmt);
20444 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20450 nk_value_bool(
struct nk_context *ctx,
const char *prefix,
int value)
20451 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %s", prefix, ((value) ?
"true":
"false"));}
20454 nk_value_int(
struct nk_context *ctx,
const char *prefix,
int value)
20455 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %d", prefix, value);}
20458 nk_value_uint(
struct nk_context *ctx,
const char *prefix,
unsigned int value)
20459 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %u", prefix, value);}
20462 nk_value_float(
struct nk_context *ctx,
const char *prefix,
float value)
20464 double double_value = (double)value;
20465 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %.3f", prefix, double_value);
20470 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%d, %d, %d, %d)", p, c.
r, c.
g, c.
b, c.
a);}
20476 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%.2f, %.2f, %.2f, %.2f)",
20477 p, c[0], c[1], c[2], c[3]);
20481 nk_value_color_hex(
struct nk_context *ctx,
const char *prefix,
struct nk_color color)
20554 struct nk_config_stack_button_behavior *button_stack;
20555 struct nk_config_stack_button_behavior_element *element;
20558 if (!ctx)
return 0;
20561 NK_ASSERT(button_stack->head < (
int)
NK_LEN(button_stack->elements));
20562 if (button_stack->head >= (
int)
NK_LEN(button_stack->elements))
20565 element = &button_stack->elements[button_stack->head++];
20575 struct nk_config_stack_button_behavior *button_stack;
20576 struct nk_config_stack_button_behavior_element *element;
20579 if (!ctx)
return 0;
20582 NK_ASSERT(button_stack->head > 0);
20583 if (button_stack->head < 1)
20586 element = &button_stack->elements[--button_stack->head];
20587 *element->address = element->old_value;
20612 if (!state)
return 0;
20623 if (!ctx)
return 0;
20657 if (!state)
return 0;
20690 if (!state)
return 0;
20700 if (!ctx)
return 0;
20725 if (!state)
return 0;
20735 if (!ctx)
return 0;
20742 const char *text,
int len, nk_flags align)
20761 if (!state)
return 0;
20770 const char* text,
int len, nk_flags align)
20773 if (!ctx)
return 0;
20778 const char *label, nk_flags align)
20783 const char *title, nk_flags align)
20789 int len, nk_flags align)
20808 if (!state)
return 0;
20817 const char *text,
int len, nk_flags align)
20822 const char *label, nk_flags align)
20827 const char *label, nk_flags text_alignment)
20837 nk_flags align,
int *value)
20856 style = &ctx->
style;
20859 if (!state)
return 0;
20867 const char *str,
int len, nk_flags align,
int *value)
20886 style = &ctx->
style;
20889 if (!state)
return 0;
20892 str, len, align, value, &img, &style->
selectable, in, style->
font);
20896 nk_flags align,
int value)
20903 const char *str, nk_flags align,
int *value)
20910 const char *str, nk_flags align,
int value)
20914 const char *str,
int len, nk_flags align,
int value)
20940 style = &ctx->
style;
20944 if (!state)
return active;
20947 text, len, NK_TOGGLE_CHECK, &style->
checkbox, in, style->
font);
20953 unsigned int flags,
unsigned int value)
20958 if (!ctx || !text)
return flags;
20959 old_active = (
int)((flags & value) &
value);
20962 else flags &= ~value;
20973 if (!ctx || !text || !active)
return 0;
20976 return old_val != *active;
20981 unsigned int *flags,
unsigned int value)
20987 if (!ctx || !text || !flags)
return 0;
20989 active = (
int)((*flags & value) &
value);
20991 if (active) *flags |=
value;
20992 else *flags &= ~value;
21002 unsigned int flags,
unsigned int value)
21009 unsigned int *flags,
unsigned int value)
21035 style = &ctx->
style;
21039 if (!state)
return state;
21042 text, len, NK_TOGGLE_OPTION, &style->
option, in, style->
font);
21053 if (!ctx || !text || !active)
return 0;
21054 old_value = *active;
21056 return old_value != *active;
21094 style = &ctx->
style;
21098 if (!state)
return ret;
21101 old_value = *value;
21103 old_value, max_value, value_step, &style->
slider, in, style->
font);
21104 return (old_value > *value || old_value < *value);
21116 float value = (float)val;
21125 float value = (float)*val;
21126 ret =
nk_slider_float(ctx, (
float)min, &value, (
float)max, (
float)step);
21156 style = &ctx->
style;
21159 if (!state)
return 0;
21164 *cur, max, is_modifyable, &style->
progress, in);
21165 return (*cur != old_value);
21169 {
nk_progress(ctx, &cur, max, modifyable);
return cur;}
21184 if (!ctx || !ctx->
current)
return;
21190 if (flags & NK_EDIT_ALWAYS_INSERT_MODE)
21200 if (!ctx || !ctx->
current)
return;
21219 if (!ctx || !memory || !len)
21226 nk_textedit_clear_state(&ctx->
text_edit, (flags & NK_EDIT_MULTILINE)?
21247 *len =
NK_MIN(*len, max-1);
21276 nk_flags ret_flags = 0;
21277 unsigned char prev_state;
21289 style = &ctx->
style;
21291 if (!state)
return state;
21297 if (flags & NK_EDIT_NO_CURSOR)
21303 if (flags & NK_EDIT_CLIPBOARD)
21308 prev_state = (
unsigned char)edit->
active;
21309 in = (flags & NK_EDIT_READ_ONLY) ? 0: in;
21311 filter, edit, &style->
edit, in, style->
font);
21319 }
else if (prev_state && !edit->
active) {
21343 nk_property_variant_int(int value, int min_value, int max_value, int step)
21345 struct nk_property_variant result;
21346 result.kind = NK_PROPERTY_INT;
21347 result.value.i =
value;
21348 result.min_value.i = min_value;
21349 result.max_value.i = max_value;
21350 result.step.i = step;
21355 nk_property_variant_float(float value, float min_value, float max_value, float step)
21357 struct nk_property_variant result;
21358 result.kind = NK_PROPERTY_FLOAT;
21359 result.value.f =
value;
21360 result.min_value.f = min_value;
21361 result.max_value.f = max_value;
21362 result.step.f = step;
21367 nk_property_variant_double(double value, double min_value, double max_value,
21370 struct nk_property_variant result;
21371 result.kind = NK_PROPERTY_DOUBLE;
21372 result.value.d =
value;
21373 result.min_value.d = min_value;
21374 result.max_value.d = max_value;
21375 result.step.d = step;
21380 nk_property(
struct nk_context *ctx,
const char *name,
struct nk_property_variant *variant,
21381 float inc_per_pixel,
const enum nk_property_filter filter)
21396 int *select_begin = 0;
21397 int *select_end = 0;
21401 int dummy_state = NK_PROPERTY_DEFAULT;
21402 int dummy_length = 0;
21403 int dummy_cursor = 0;
21404 int dummy_select_begin = 0;
21405 int dummy_select_end = 0;
21415 style = &ctx->
style;
21420 if (name[0] ==
'#') {
21434 buffer = dummy_buffer;
21435 len = &dummy_length;
21436 cursor = &dummy_cursor;
21437 state = &dummy_state;
21438 select_begin = &dummy_select_begin;
21439 select_end = &dummy_select_end;
21443 old_state = *state;
21448 variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
21452 if (in && *state != NK_PROPERTY_DEFAULT && !win->
property.
active) {
21462 if (*state == NK_PROPERTY_DRAG) {
21468 if (*state == NK_PROPERTY_DEFAULT && old_state != NK_PROPERTY_DEFAULT) {
21469 if (old_state == NK_PROPERTY_DRAG) {
21482 int min,
int *val,
int max,
int step,
float inc_per_pixel)
21484 struct nk_property_variant variant;
21489 if (!ctx || !ctx->
current || !name || !val)
return;
21490 variant = nk_property_variant_int(*val, min, max, step);
21491 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
21492 *val = variant.value.i;
21497 float min,
float *val,
float max,
float step,
float inc_per_pixel)
21499 struct nk_property_variant variant;
21504 if (!ctx || !ctx->
current || !name || !val)
return;
21505 variant = nk_property_variant_float(*val, min, max, step);
21506 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21507 *val = variant.value.f;
21512 double min,
double *val,
double max,
double step,
float inc_per_pixel)
21514 struct nk_property_variant variant;
21519 if (!ctx || !ctx->
current || !name || !val)
return;
21520 variant = nk_property_variant_double(*val, min, max, step);
21521 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21522 *val = variant.value.d;
21527 int max,
int step,
float inc_per_pixel)
21529 struct nk_property_variant variant;
21533 if (!ctx || !ctx->
current || !name)
return val;
21534 variant = nk_property_variant_int(val, min, max, step);
21535 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
21536 val = variant.value.i;
21542 float val,
float max,
float step,
float inc_per_pixel)
21544 struct nk_property_variant variant;
21548 if (!ctx || !ctx->
current || !name)
return val;
21549 variant = nk_property_variant_float(val, min, max, step);
21550 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21551 val = variant.value.f;
21557 double val,
double max,
double step,
float inc_per_pixel)
21559 struct nk_property_variant variant;
21563 if (!ctx || !ctx->
current || !name)
return val;
21564 variant = nk_property_variant_double(val, min, max, step);
21565 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21566 val = variant.value.d;
21595 config = &ctx->
style;
21598 if (!state)
return 0;
21620 int count,
float min_value,
float max_value)
21628 struct nk_rect bounds = {0, 0, 0, 0};
21637 nk_zero(chart,
sizeof(*chart));
21642 config = &ctx->
style;
21644 style = &config->
chart;
21647 nk_zero(chart,
sizeof(*chart));
21661 slot->
min =
NK_MIN(min_value, max_value);
21662 slot->
max =
NK_MAX(min_value, max_value);
21679 int count,
float min_value,
float max_value)
21685 int count,
float min_value,
float max_value)
21701 slot->
min =
NK_MIN(min_value, max_value);
21702 slot->
max =
NK_MAX(min_value, max_value);
21708 int count,
float min_value,
float max_value)
21713 struct nk_chart *g,
float value,
int slot)
21730 ratio = (value - g->
slots[slot].
min) / range;
21735 g->
slots[slot].
last.
y = (g->
y + g->
h) - ratio * (
float)g->
h;
21739 bounds.
w = bounds.
h = 4;
21756 cur.x = g->
x + (float)(step * (
float)g->
slots[slot].
index);
21757 cur.y = (g->
y + g->
h) - (ratio * (
float)g->
h);
21760 bounds.
x = cur.x - 3;
21761 bounds.
y = cur.y - 3;
21762 bounds.
w = bounds.
h = 6;
21784 struct nk_chart *chart,
float value,
int slot)
21793 struct nk_rect item = {0,0,0,0};
21799 float padding = (float)(chart->
slots[slot].
count-1);
21800 item.
w = (chart->
w - padding) / (
float)(chart->
slots[slot].
count);
21808 item.
y = (chart->
y + chart->
h) - chart->
h * ratio;
21811 item.
y = chart->
y + (chart->
h *
NK_ABS(ratio)) - item.
h;
21813 item.
x = chart->
x + ((float)chart->
slots[slot].
index * item.
w);
21838 NK_ASSERT(slot < ctx->
current->layout->chart.slot);
21846 flags = nk_chart_push_line(ctx, win, &win->
layout->
chart, value, slot);
break;
21848 flags = nk_chart_push_column(ctx, win, &win->
layout->
chart, value, slot);
break;
21873 NK_MEMSET(chart, 0,
sizeof(*chart));
21879 int count,
int offset)
21887 if (!ctx || !values || !count)
return;
21889 min_value = values[offset];
21890 max_value = values[offset];
21891 for (i = 0; i < count; ++i) {
21892 min_value =
NK_MIN(values[i + offset], min_value);
21893 max_value =
NK_MAX(values[i + offset], max_value);
21897 for (i = 0; i < count; ++i)
21905 float(*value_getter)(
void* user,
int index),
int count,
int offset)
21912 NK_ASSERT(value_getter);
21913 if (!ctx || !value_getter || !count)
return;
21915 max_value = min_value = value_getter(userdata, offset);
21916 for (i = 0; i < count; ++i) {
21917 float value = value_getter(userdata, i + offset);
21918 min_value =
NK_MIN(value, min_value);
21919 max_value =
NK_MAX(value, max_value);
21923 for (i = 0; i < count; ++i)
21936 nk_uint *x_offset, nk_uint *y_offset,
const char *title, nk_flags flags)
21943 nk_panel_alloc_space(&bounds, ctx);
21953 nk_zero(&panel,
sizeof(panel));
21954 panel.bounds = bounds;
21955 panel.flags = flags;
21956 panel.scrollbar.
x = *x_offset;
21957 panel.scrollbar.y = *y_offset;
21958 panel.buffer = win->
buffer;
21959 panel.layout = (
struct nk_panel*)nk_create_panel(ctx);
21963 win->
buffer = panel.buffer;
21965 panel.layout->offset_x = x_offset;
21966 panel.layout->offset_y = y_offset;
21967 panel.layout->parent = win->
layout;
21968 win->
layout = panel.layout;
21974 nk_flags f = panel.layout->flags;
21993 struct nk_vec2 panel_padding;
22012 pan.bounds.x = g->
bounds.
x - panel_padding.x;
22013 pan.bounds.w = g->
bounds.
w + 2 * panel_padding.x;
22015 if (g->
flags & NK_WINDOW_BORDER) {
22016 pan.bounds.x -= g->
border;
22017 pan.bounds.y -= g->
border;
22018 pan.bounds.w += 2*g->
border;
22019 pan.bounds.h += 2*g->
border;
22027 pan.flags = g->
flags;
22028 pan.buffer = win->
buffer;
22034 nk_unify(&clip, &parent->
clip, pan.bounds.
x, pan.bounds.y,
22035 pan.bounds.x + pan.bounds.w, pan.bounds.y + pan.bounds.h + panel_padding.x);
22039 win->
buffer = pan.buffer;
22049 struct nk_scroll *scroll,
const char *title, nk_flags flags)
22056 nk_hash title_hash;
22072 x_offset = nk_find_value(win, title_hash);
22074 x_offset = nk_add_value(ctx, win, title_hash, 0);
22075 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
22077 NK_ASSERT(x_offset);
22078 NK_ASSERT(y_offset);
22079 if (!x_offset || !y_offset)
return 0;
22080 *x_offset = *y_offset = 0;
22081 }
else y_offset = nk_find_value(win, title_hash+1);
22091 const char *title, nk_flags flags,
int row_height,
int row_count)
22094 nk_hash title_hash;
22107 if (!ctx || !view || !title)
return 0;
22110 style = &ctx->
style;
22112 row_height +=
NK_MAX(0, (
int)item_spacing.y);
22117 x_offset = nk_find_value(win, title_hash);
22119 x_offset = nk_add_value(ctx, win, title_hash, 0);
22120 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
22122 NK_ASSERT(x_offset);
22123 NK_ASSERT(y_offset);
22124 if (!x_offset || !y_offset)
return 0;
22125 *x_offset = *y_offset = 0;
22126 }
else y_offset = nk_find_value(win, title_hash+1);
22151 NK_ASSERT(view->
ctx);
22153 if (!view || !view->
ctx)
return;
22170 const char *title, nk_flags flags,
struct nk_rect rect)
22177 nk_hash title_hash;
22196 popup = (
struct nk_window*)nk_create_window(ctx);
22206 nk_zero(popup,
sizeof(*popup));
22229 nk_start_popup(ctx, win);
22259 nk_free_panel(ctx, popup->
layout);
22289 popup = (
struct nk_window*)nk_create_window(ctx);
22296 int pressed, in_body, in_header;
22300 if (pressed && (!in_body || in_header))
22323 NK_ASSERT(popup->
layout);
22325 nk_start_popup(ctx, win);
22330 nk_panel_begin(ctx, 0, panel_type);
22351 if (!ctx || !ctx->
current)
return;
22354 NK_ASSERT(popup->
parent);
22372 if (!popup->
parent)
return;
22387 nk_finish_popup(ctx, win);
22417 bounds.
h = nk_null_rect.h;
22434 if (!ctx || !ctx->
current)
return;
22458 style = &ctx->
style;
22465 text_width += (4 * padding.x);
22466 text_height = (style->
font->
height + 2 * padding.y);
22482 struct nk_rect trigger_bounds)
22489 int is_clicked = 0;
22509 if ((is_clicked && is_open && !is_active) || (!is_open && !is_active && !is_clicked))
22538 nk_flags alignment)
22554 style = &ctx->
style;
22572 const char *text,
int len, nk_flags align)
22588 style = &ctx->
style;
22602 const char *label, nk_flags align)
22607 const char *text,
int len, nk_flags align)
22623 style = &ctx->
style;
22637 const char *text, nk_flags align)
22657 if (!ctx || !ctx->
current)
return;
22661 NK_ASSERT(popup->
parent);
22669 struct nk_rect body = {0,0,0,0};
22678 if (pressed && in_body)
22717 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
22718 (!is_open && !is_active && !is_clicked))
return 0;
22719 if (!nk_nonblock_begin(ctx, 0, body,
22742 NK_ASSERT(selected);
22749 style = &ctx->
style;
22770 text.background =
nk_rgba(0,0,0,0);
22773 text.background = background->
data.
color;
22786 else if (is_clicked)
22794 button.h = button.w;
22807 nk_widget_text(&win->
buffer, label, selected, len, &text,
22814 return nk_combo_begin(ctx, win, size, is_clicked, header);
22839 style = &ctx->
style;
22869 else if (is_clicked)
22877 button.h = button.w;
22895 return nk_combo_begin(ctx, win, size, is_clicked, header);
22919 style = &ctx->
style;
22941 sym_background =
nk_rgba(0,0,0,0);
22944 sym_background = background->
data.
color;
22949 struct nk_rect bounds = {0,0,0,0};
22956 else if (is_clicked)
22964 button.h = button.w;
22976 nk_draw_symbol(&win->
buffer, symbol, bounds, sym_background, symbol_color,
22977 1.0f, style->
font);
22983 return nk_combo_begin(ctx, win, size, is_clicked, header);
23008 style = &ctx->
style;
23031 text.background =
nk_rgba(0,0,0,0);
23034 text.background = background->
data.
color;
23047 else if (is_clicked)
23055 button.h = button.w;
23069 nk_draw_symbol(&win->
buffer, symbol, image, text.background, symbol_color,
23070 1.0f, style->
font);
23080 return nk_combo_begin(ctx, win, size, is_clicked, header);
23102 style = &ctx->
style;
23125 struct nk_rect bounds = {0,0,0,0};
23132 else if (is_clicked)
23140 button.h = button.w;
23158 return nk_combo_begin(ctx, win, size, is_clicked, header);
23182 style = &ctx->
style;
23202 text.background =
nk_rgba(0,0,0,0);
23205 text.background = background->
data.
color;
23218 else if (is_clicked)
23226 button.h = button.w;
23250 return nk_combo_begin(ctx, win, size, is_clicked, header);
23268 int len, nk_flags alignment)
23272 const char *text, nk_flags alignment)
23276 const char *text,
int len, nk_flags alignment)
23280 const char *label, nk_flags alignment)
23291 int selected,
int item_height,
struct nk_vec2 size)
23296 struct nk_vec2 window_padding;
23301 if (!ctx || !items ||!count)
23306 max_height = count * item_height + count * (
int)item_spacing.y;
23307 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23308 size.
y =
NK_MIN(size.
y, (
float)max_height);
23311 for (i = 0; i < count; ++i) {
23322 int separator,
int selected,
int count,
int item_height,
struct nk_vec2 size)
23327 struct nk_vec2 window_padding;
23328 const char *current_item;
23333 NK_ASSERT(items_separated_by_separator);
23334 if (!ctx || !items_separated_by_separator)
23340 max_height = count * item_height + count * (
int)item_spacing.y;
23341 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23342 size.
y =
NK_MIN(size.
y, (
float)max_height);
23345 current_item = items_separated_by_separator;
23346 for (i = 0; i < count; ++i) {
23347 iter = current_item;
23348 while (*iter && *iter != separator) iter++;
23349 length = (
int)(iter - current_item);
23350 if (i == selected)
break;
23351 current_item = iter + 1;
23355 current_item = items_separated_by_separator;
23357 for (i = 0; i < count; ++i) {
23358 iter = current_item;
23359 while (*iter && *iter != separator) iter++;
23360 length = (
int)(iter - current_item);
23363 current_item = current_item + length + 1;
23372 int selected,
int count,
int item_height,
struct nk_vec2 size)
23373 {
return nk_combo_separator(ctx, items_separated_by_zeros,
'\0', selected, count, item_height, size);}
23377 void *userdata,
int selected,
int count,
int item_height,
struct nk_vec2 size)
23382 struct nk_vec2 window_padding;
23386 NK_ASSERT(item_getter);
23387 if (!ctx || !item_getter)
23393 max_height = count * item_height + count * (
int)item_spacing.y;
23394 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23395 size.
y =
NK_MIN(size.
y, (
float)max_height);
23397 item_getter(userdata, selected, &item);
23400 for (i = 0; i < count; ++i) {
23401 item_getter(userdata, i, &item);
23411 int *selected,
int item_height,
struct nk_vec2 size)
23412 {*selected =
nk_combo(ctx, items, count, *selected, item_height, size);}
23415 int *selected,
int count,
int item_height,
struct nk_vec2 size)
23416 {*selected =
nk_combo_string(ctx, items_separated_by_zeros, *selected, count, item_height, size);}
23419 int separator,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
23421 *selected, count, item_height, size);}
23424 void(*item_getter)(
void* data,
int id,
const char **out_text),
23425 void *userdata,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
23426 {*selected =
nk_combo_callback(ctx, item_getter, userdata, *selected, count, item_height, size);}
23437 const char *
id,
int is_clicked,
struct nk_rect header,
struct nk_vec2 size)
23453 body.
y = header.
y + header.
h;
23459 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
23460 (!is_open && !is_active && !is_clicked))
return 0;
23471 nk_flags align,
struct nk_vec2 size)
23487 if (!state)
return 0;
23492 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23496 const char *text, nk_flags align,
struct nk_vec2 size)
23517 if (!state)
return 0;
23522 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
23543 if (!state)
return 0;
23548 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
23569 if (!state)
return 0;
23575 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23579 const char *title, nk_flags align,
struct nk_image img,
struct nk_vec2 size)
23600 if (!state)
return 0;
23606 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23620 const char *label, nk_flags align)
23624 const char *text,
int len, nk_flags align)
23628 const char *text,
int len, nk_flags align)
23632 const char *label, nk_flags align)
Definition: nuklear.h:2021
unsigned short r
Definition: nuklear.h:3063
struct nk_vec2 padding
Definition: nuklear.h:3630
Definition: nuklear.h:3126
Definition: nuklear.h:2146
NK_API struct nk_color nk_rgb_iv(const int *rgb)
struct nk_command header
Definition: nuklear.h:2976
Definition: nuklear.h:689
short cx
Definition: nuklear.h:3062
NK_API int nk_menu_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_style_item hover
Definition: nuklear.h:3580
nk_chart_event
Definition: nuklear.h:472
struct nk_vec2 padding
Definition: nuklear.h:3536
float preferred_x
Definition: nuklear.h:2860
struct nk_style_item hover_active
Definition: nuklear.h:3452
NK_API int nk_window_has_focus(const struct nk_context *)
NK_API int nk_menu_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
Definition: nuklear.h:3850
struct nk_style_button dec_button
Definition: nuklear.h:3634
NK_API struct nk_rect nk_rectv(const float *xywh)
nk_handle userdata
Definition: nuklear.h:3539
Definition: nuklear.h:2009
#define NK_CONFIG_STACK(type, size)
Definition: nuklear.h:4054
struct nk_style_item cursor_hover
Definition: nuklear.h:3423
struct nk_command header
Definition: nuklear.h:3029
NK_API int nk_input_mouse_clicked(const struct nk_input *, enum nk_buttons, struct nk_rect)
struct nk_pool pool
Definition: nuklear.h:4161
struct nk_style_item active
Definition: nuklear.h:3483
NK_API int nk_select_text(struct nk_context *, const char *, int, nk_flags align, int value)
NK_API int nk_tree_state_image_push(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state)
unsigned int scrolled
Definition: nuklear.h:3985
NK_API void nk_window_set_position(struct nk_context *, struct nk_vec2 pos)
NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba)
float menu_border
Definition: nuklear.h:3754
NK_API int nk_contextual_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
NK_API void nk_textedit_select_all(struct nk_text_edit *)
Definition: nuklear.h:3060
nk_convert_result
Definition: nuklear.h:970
NK_API int nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align)
NK_API int nk_contextual_begin(struct nk_context *, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds)
struct nk_vec2 last
Definition: nuklear.h:3835
struct nk_color text_hover
Definition: nuklear.h:3457
Definition: nuklear.h:3829
Definition: nuklear.h:3051
void * memory
Definition: nuklear.h:2657
struct nk_style_item cursor_normal
Definition: nuklear.h:3422
NK_API void nk_color_hex_rgb(char *output, struct nk_color)
Definition: nuklear.h:2160
float border
Definition: nuklear.h:3895
NK_API struct nk_rect nk_get_null_rect(void)
nk_buffer_allocation_type
Definition: nuklear.h:2670
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
void *(* nk_plugin_alloc)(nk_handle, void *old, nk_size)
Definition: nuklear.h:478
struct nk_color color
Definition: nuklear.h:3065
#define NK_STORAGE
Definition: nuklear.h:287
nk_handle userdata
Definition: nuklear.h:3513
nk_widget_states
Definition: nuklear.h:1835
void(* nk_plugin_paste)(nk_handle, struct nk_text_edit *)
Definition: nuklear.h:481
Definition: nuklear.h:1184
float tooltip_border
Definition: nuklear.h:3756
float max_x
Definition: nuklear.h:3892
#define NK_INT32
Definition: nuklear.h:352
NK_API int nk_contextual_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_default(const struct nk_text_edit *, nk_rune unicode)
unsigned int page_count
Definition: nuklear.h:4122
nk_size allocated
Definition: nuklear.h:2693
unsigned short w
Definition: nuklear.h:3012
NK_API void nk_stroke_circle(struct nk_command_buffer *, struct nk_rect, float line_thickness, struct nk_color)
NK_API struct nk_vec2 nk_vec2i(int x, int y)
Definition: nuklear.h:1183
struct nk_vec2 contextual_padding
Definition: nuklear.h:3769
Definition: nuklear.h:2161
nk_panel_flags
Definition: nuklear.h:1173
NK_API int nk_utf_decode(const char *, nk_rune *, int)
struct nk_style_button menu_button
Definition: nuklear.h:3784
Definition: nuklear.h:2015
NK_API struct nk_color nk_rgba_u32(nk_uint)
nk_size needed
Definition: nuklear.h:2695
NK_API int nk_filter_hex(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_menu_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
float bar_height
Definition: nuklear.h:3500
unsigned short w
Definition: nuklear.h:3005
NK_API void nk_buffer_init(struct nk_buffer *, const struct nk_allocator *, nk_size size)
NK_API int nk_button_color(struct nk_context *, struct nk_color)
unsigned short h
Definition: nuklear.h:3047
NK_API int nk_select_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int value)
NK_API struct nk_window * nk_window_find(struct nk_context *ctx, const char *name)
NK_API void nk_str_remove_chars(struct nk_str *, int len)
NK_API int nk_widget_is_hovered(struct nk_context *)
#define NK_FLAGS_STACK_SIZE
Definition: nuklear.h:4042
NK_API void nk_layout_row_end(struct nk_context *)
Definition: nuklear.h:2939
Definition: nuklear.h:664
NK_API void nk_fill_circle(struct nk_command_buffer *, struct nk_rect, struct nk_color)
NK_API void nk_window_set_size(struct nk_context *, struct nk_vec2)
struct nk_vec2 padding
Definition: nuklear.h:3384
#define nk_zero_struct(s)
Definition: nuklear.h:4197
struct nk_image img
Definition: nuklear.h:462
Definition: nuklear.h:3925
Definition: deflate.c:117
Definition: nuklear.h:2672
nk_handle handle
Definition: nuklear.h:461
float border
Definition: nuklear.h:3628
Definition: nuklear.h:453
unsigned int seq
Definition: nuklear.h:3945
Definition: nuklear.h:3821
short x
Definition: nuklear.h:2971
enum nk_symbol_type sym_left
Definition: nuklear.h:3624
struct nk_config_stack_button_behavior button_behaviors
Definition: nuklear.h:4084
struct nk_rect clip
Definition: nuklear.h:3897
short y
Definition: nuklear.h:3011
Definition: nuklear.h:670
nk_modify
Definition: nuklear.h:467
Definition: nuklear.h:484
struct nk_color selected_text_hover
Definition: nuklear.h:3600
NK_API int nk_combo_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *userdata, int selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, int down)
short h
Definition: nuklear.h:458
NK_API void nk_str_init_fixed(struct nk_str *, void *memory, nk_size size)
Definition: nuklear.h:3943
struct nk_color col
Definition: nuklear.h:3096
NK_API int nk_popup_begin(struct nk_context *, enum nk_popup_type, const char *, nk_flags, struct nk_rect bounds)
NK_API void nk_property_float(struct nk_context *, const char *name, float min, float *val, float max, float step, float inc_per_pixel)
NK_API void nk_layout_row_template_push_variable(struct nk_context *, float min_width)
nk_style_header_align
Definition: nuklear.h:3708
struct nk_vec2 touch_padding
Definition: nuklear.h:3434
Definition: nuklear.h:2007
NK_API int nk_button_text_styled(struct nk_context *, const struct nk_style_button *, const char *title, int len)
struct nk_row_layout row
Definition: nuklear.h:3899
unsigned short line_thickness
Definition: nuklear.h:3086
unsigned int seq
Definition: nuklear.h:4094
struct nk_style_button node_maximize_button
Definition: nuklear.h:3695
NK_API void nk_layout_space_push(struct nk_context *, struct nk_rect)
NK_API void nk_layout_row_template_push_static(struct nk_context *, float width)
int cursor
Definition: nuklear.h:3960
NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color)
struct nk_vec2 tooltip_padding
Definition: nuklear.h:3771
Definition: nuklear.h:465
NK_API void nk_combobox_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *, int *selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_combo_item_text(struct nk_context *, const char *, int, nk_flags alignment)
Definition: nuklear.h:683
NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context *, nk_flags, char *buffer, int max, nk_plugin_filter)
struct nk_window * current
Definition: nuklear.h:4165
NK_API void nk_text(struct nk_context *, const char *, int, nk_flags)
nk_flags flags
Definition: nuklear.h:3973
Definition: nuklear.h:2952
Definition: nuklear.h:3817
struct nk_color color
Definition: nuklear.h:3033
Definition: nuklear.h:3826
Definition: nuklear.h:4119
nk_uint values[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:4097
Definition: nuklear.h:1998
float border
Definition: nuklear.h:3650
NK_API int nk_select_label(struct nk_context *, const char *, nk_flags align, int value)
float h
Definition: nuklear.h:3841
NK_API int nk_menu_item_label(struct nk_context *, const char *, nk_flags alignment)
struct nk_color color
Definition: nuklear.h:2980
Definition: nuklear.h:3854
float cursor_size
Definition: nuklear.h:3605
NK_API struct nk_rect nk_layout_widget_bounds(struct nk_context *)
struct nk_vec2i c
Definition: nuklear.h:3024
struct nk_color selected_text_normal
Definition: nuklear.h:3599
Definition: nuklear.h:3642
float w
Definition: nuklear.h:3841
Definition: nuklear.h:1871
NK_API int nk_button_symbol_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type)
float item_height
Definition: nuklear.h:3865
struct nk_color color
Definition: nuklear.h:2989
struct nk_chart_slot slots[NK_CHART_MAX_SLOT]
Definition: nuklear.h:3842
float border
Definition: nuklear.h:3436
struct nk_color text_normal_active
Definition: nuklear.h:3461
char nk_glyph[NK_UTF_SIZE]
Definition: nuklear.h:459
nk_plugin_free free
Definition: nuklear.h:487
NK_POINTER_TYPE nk_ptr
Definition: nuklear.h:402
NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context *, struct nk_rect)
Definition: nuklear.h:492
nk_handle texture
Definition: nuklear.h:978
Definition: nuklear.h:1799
NK_API struct nk_color nk_hsv(int h, int s, int v)
struct nk_chart chart
Definition: nuklear.h:3900
struct nk_color tooltip_border_color
Definition: nuklear.h:3748
struct nk_vec2 image_padding
Definition: nuklear.h:3471
int where
Definition: nuklear.h:2818
nk_flags text_alignment
Definition: nuklear.h:3465
struct nk_vec2 cursor_size
Definition: nuklear.h:3503
struct nk_color group_border_color
Definition: nuklear.h:3747
struct nk_style_item scaler
Definition: nuklear.h:3749
Definition: nuklear.h:1174
#define NK_ABS(a)
Definition: nuklear.h:4181
nk_buttons
Definition: nuklear.h:695
NK_API void nk_edit_focus(struct nk_context *, nk_flags flags)
unsigned short point_count
Definition: nuklear.h:3072
Definition: nuklear.h:476
#define NK_MAX_FLOAT_PRECISION
Definition: nuklear.h:4176
#define NK_MAX_NUMBER_BUFFER
Definition: nuklear.h:260
unsigned char ungrab
Definition: nuklear.h:3176
short insert_length
Definition: nuklear.h:2819
short x
Definition: nuklear.h:3038
Definition: nuklear.h:3846
nk_edit_types
Definition: nuklear.h:2011
NK_API struct nk_color nk_hsv_fv(const float *hsv)
NK_API struct nk_style_item nk_style_item_image(struct nk_image img)
Definition: nuklear.h:2014
nk_anti_aliasing
Definition: nuklear.h:969
NK_API int nk_widget_is_mouse_clicked(struct nk_context *, enum nk_buttons)
struct nk_color bar_hover
Definition: nuklear.h:3488
struct nk_style_progress progress
Definition: nuklear.h:3789
NK_API void nk_window_collapse(struct nk_context *, const char *name, enum nk_collapse_states state)
Definition: nuklear.h:3815
short y
Definition: nuklear.h:458
Definition: nuklear.h:2174
NK_API void nk_button_set_behavior(struct nk_context *, enum nk_button_behavior)
nk_handle userdata
Definition: nuklear.h:2812
NK_API void nk_group_end(struct nk_context *)
NK_API int nk_input_is_key_pressed(const struct nk_input *, enum nk_keys)
unsigned short point_count
Definition: nuklear.h:3079
struct nk_style_item normal
Definition: nuklear.h:3446
#define NK_FLAG(x)
Definition: nuklear.h:290
unsigned short w
Definition: nuklear.h:2997
int32_t current
Definition: netobject.cpp:37
unsigned short line_thickness
Definition: nuklear.h:2977
#define NK_UTF_INVALID
Definition: nuklear.h:4175
unsigned short h
Definition: nuklear.h:3094
struct nk_color top
Definition: nuklear.h:3014
Definition: nuklear.h:3816
struct nk_property_state property
Definition: nuklear.h:3982
NK_API void nk_layout_space_end(struct nk_context *)
#define NK_GLOBAL
Definition: nuklear.h:288
struct nk_style_item active
Definition: nuklear.h:3581
struct nk_style_item cursor_hover
Definition: nuklear.h:3494
nk_flags flags
Definition: nuklear.h:3888
struct nk_color border_color
Definition: nuklear.h:3742
struct nk_color text_pressed
Definition: nuklear.h:3458
Definition: nuklear.h:2022
NK_API void nk_layout_row_template_push_dynamic(struct nk_context *)
short y
Definition: nuklear.h:2996
float min
Definition: nuklear.h:3833
unsigned short w
Definition: nuklear.h:3094
struct nk_page_element * freelist
Definition: nuklear.h:4166
Definition: nuklear.h:2844
Definition: nuklear.h:3009
struct nk_vec2i c
Definition: nuklear.h:3032
struct nk_style_selectable selectable
Definition: nuklear.h:3787
NK_API int nk_str_insert_str_runes(struct nk_str *, int pos, const nk_rune *)
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3638
enum nk_symbol_type sym_minimize
Definition: nuklear.h:3697
struct nk_style_button inc_button
Definition: nuklear.h:3507
nk_handle userdata
Definition: nuklear.h:3439
#define NK_ALIGNOF(t)
Definition: nuklear.h:4240
Definition: nuklear.h:969
struct nk_style_window window
Definition: nuklear.h:3797
float height
Definition: nuklear.h:3860
unsigned char grab
Definition: nuklear.h:3174
int select_start
Definition: nuklear.h:2851
struct nk_vec2i ctrl[2]
Definition: nuklear.h:2988
float group_border
Definition: nuklear.h:3755
NK_API void nk_stroke_triangle(struct nk_command_buffer *, float, float, float, float, float, float, float line_thichness, struct nk_color)
NK_SIZE_TYPE nk_size
Definition: nuklear.h:401
unsigned short w
Definition: nuklear.h:2972
Definition: nuklear.h:3914
unsigned short line_thickness
Definition: nuklear.h:3021
struct nk_color border_color
Definition: nuklear.h:3582
struct nk_color text_normal
Definition: nuklear.h:3456
nk_panel_row_layout_type
Definition: nuklear.h:3845
struct nk_style_button contextual_button
Definition: nuklear.h:3783
Definition: nuklear.h:3179
NK_API void nk_label_wrap(struct nk_context *, const char *)
NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv)
Definition: nuklear.h:465
NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score)
NK_API void nk_window_set_focus(struct nk_context *, const char *name)
Definition: nuklear.h:1175
Definition: nuklear.h:2150
NK_API void nk_str_delete_runes(struct nk_str *, int pos, int len)
#define NK_POINTER_TYPE
Definition: nuklear.h:389
Definition: nuklear.h:663
::std::string string
Definition: gtest-port.h:872
unsigned int seq
Definition: nuklear.h:3964
NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva)
#define SEEK_END
Definition: zconf.h:390
NK_API int nk_utf_encode(nk_rune, char *, int)
NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color)
nk_byte r
Definition: nuklear.h:453
float a[2]
Definition: nuklear.h:3056
Definition: nuklear.h:2839
NK_API int nk_str_append_text_char(struct nk_str *, const char *, int)
struct nk_color border_color
Definition: nuklear.h:3660
NK_API void nk_fill_rect_multi_color(struct nk_command_buffer *, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom)
struct nk_memory memory
Definition: nuklear.h:2689
NK_API void nk_list_view_end(struct nk_list_view *)
struct nk_color color
Definition: nuklear.h:3085
float header_height
Definition: nuklear.h:3894
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3541
NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context *, struct nk_vec2)
struct nk_image img
Definition: nuklear.h:3095
NK_API char * nk_str_at_rune(struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_mouse_button buttons[NK_BUTTON_MAX]
Definition: nuklear.h:3169
Definition: nuklear.h:1843
unsigned char has_preferred_x
Definition: nuklear.h:2856
NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context *, struct nk_rect)
struct nk_window * parent
Definition: nuklear.h:3993
int index
Definition: nuklear.h:3859
Definition: nuklear.h:458
union nk_style_item_data data
Definition: nuklear.h:3379
float border
Definition: nuklear.h:3498
Definition: nuklear.h:691
NK_API nk_uint nk_color_u32(struct nk_color)
NK_API struct nk_vec2 nk_widget_position(struct nk_context *)
struct nk_color background
Definition: nuklear.h:3740
NK_API int nk_button_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_ascii(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:3819
struct nk_color bottom
Definition: nuklear.h:3015
nk_popup_type
Definition: nuklear.h:474
int prev
Definition: nuklear.h:3957
NK_API int nk_contextual_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_page_element * next
Definition: nuklear.h:4109
nk_uint nk_flags
Definition: nuklear.h:405
float at_x
Definition: nuklear.h:3892
Definition: nuklear.h:3368
NK_API int nk_str_insert_text_char(struct nk_str *, int pos, const char *, int)
int count
Definition: nuklear.h:3834
struct nk_window * active
Definition: nuklear.h:4164
struct nk_color highlight
Definition: nuklear.h:3832
struct nk_color color
Definition: nuklear.h:3647
float rounding
Definition: nuklear.h:3702
float at_y
Definition: nuklear.h:3892
Definition: nuklear.h:2946
struct nk_style_text text
Definition: nuklear.h:3781
struct nk_vec2i b
Definition: nuklear.h:3031
nk_handle userdata
Definition: nuklear.h:3474
struct nk_color text_pressed_active
Definition: nuklear.h:3463
struct nk_color label_normal
Definition: nuklear.h:3663
struct nk_color combo_border_color
Definition: nuklear.h:3744
NK_API void nk_textedit_text(struct nk_text_edit *, const char *, int total_len)
NK_API void nk_str_delete_chars(struct nk_str *, int pos, int len)
Definition: nuklear.h:2955
struct nk_color color
Definition: nuklear.h:3374
struct nk_allocator alloc
Definition: nuklear.h:4120
NK_API int nk_str_append_text_runes(struct nk_str *, const nk_rune *, int)
#define NK_INT8
Definition: nuklear.h:337
nk_command_custom_callback callback
Definition: nuklear.h:3106
Definition: nuklear.h:668
std::mutex m
Definition: faio.cpp:21
NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color)
Definition: nuklear.h:2666
NK_INT8 nk_char
Definition: nuklear.h:394
NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color)
Definition: nuklear.h:2001
struct nk_table * tables
Definition: nuklear.h:3987
struct nk_vec2 scrollbar_size
Definition: nuklear.h:3762
NK_API int nk_strtoi(const char *str, const char **endptr)
float max
Definition: nuklear.h:3833
struct nk_vec2 prev
Definition: nuklear.h:3171
enum nk_symbol_type sym_normal
Definition: nuklear.h:3674
Definition: nuklear.h:2000
Definition: nuklear.h:2841
struct nk_table * next
Definition: nuklear.h:4098
struct nk_style_item cursor_hover
Definition: nuklear.h:3527
struct nk_key keys[NK_KEY_MAX]
Definition: nuklear.h:3184
Definition: nuklear.h:4093
NK_API struct nk_style_item nk_style_item_hide(void)
NK_API int nk_combo_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
unsigned short line_thickness
Definition: nuklear.h:3071
NK_API void nk_label(struct nk_context *, const char *, nk_flags align)
nk_byte g
Definition: nuklear.h:453
Definition: nuklear.h:1836
NK_API int nk_style_set_cursor(struct nk_context *, enum nk_style_cursor)
Definition: nuklear.h:3839
int count
Definition: nuklear.h:1801
NK_API const struct nk_command * nk__next(struct nk_context *, const struct nk_command *)
nk_tree_type
Definition: nuklear.h:476
NK_API int nk_stricmp(const char *s1, const char *s2)
Definition: nuklear.h:3611
NK_API int nk_str_insert_at_rune(struct nk_str *, int pos, const char *, int)
NK_API void nk_plot(struct nk_context *, enum nk_chart_type, const float *values, int count, int offset)
unsigned curve_segment_count
Definition: nuklear.h:987
nk_panel_type
Definition: nuklear.h:3814
short undo_point
Definition: nuklear.h:2827
int cursor
Definition: nuklear.h:2850
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3514
float delta_time_seconds
Definition: nuklear.h:4139
NK_API void nk_contextual_end(struct nk_context *)
NK_API int nk_combo_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
struct nk_command_buffer overlay
Definition: nuklear.h:4156
struct nk_command header
Definition: nuklear.h:2993
NK_API int nk_progress(struct nk_context *, nk_size *cur, nk_size max, int modifyable)
float rounding
Definition: nuklear.h:3532
short y
Definition: nuklear.h:3093
nk_size needed
Definition: nuklear.h:2661
struct nk_style_item normal
Definition: nuklear.h:3657
struct nk_vec2i begin
Definition: nuklear.h:2978
Definition: nuklear.h:1864
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3475
struct nk_buffer buffer
Definition: nuklear.h:2729
struct nk_vec2i a
Definition: nuklear.h:3022
struct nk_style_item active
Definition: nuklear.h:3522
struct nk_style_edit edit
Definition: nuklear.h:3791
NK_API int nk_window_is_any_hovered(struct nk_context *)
Definition: nuklear.h:473
Definition: nuklear.h:3168
NK_API struct nk_vec2 nk_vec2iv(const int *xy)
unsigned short h
Definition: nuklear.h:2972
short cy
Definition: nuklear.h:3053
Definition: nuklear.h:969
unsigned char cursor_at_end_of_line
Definition: nuklear.h:2854
float border
Definition: nuklear.h:3751
NK_API int nk_combo_begin_text(struct nk_context *, const char *selected, int, struct nk_vec2 size)
#define NK_BUTTON_BEHAVIOR_STACK_SIZE
Definition: nuklear.h:4022
struct nk_style_button dec_button
Definition: nuklear.h:3508
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
struct nk_style_item pressed_active
Definition: nuklear.h:3453
Definition: nuklear.h:475
nk_button_behavior
Definition: nuklear.h:466
NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context *, struct nk_vec2)
NK_API int nk_style_pop_float(struct nk_context *)
short y
Definition: nuklear.h:3103
float rounding
Definition: nuklear.h:3629
NK_API struct nk_rect nk_layout_space_bounds(struct nk_context *)
float min_row_height_padding
Definition: nuklear.h:3758
struct nk_table * prev
Definition: nuklear.h:4098
#define NK_INCLUDE_COMMAND_USERDATA
Definition: fa_nuklear.h:14
NK_API int nk_button_image_text_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, int, nk_flags alignment)
NK_API int nk_init_custom(struct nk_context *, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *)
struct nk_vec2i points[1]
Definition: nuklear.h:3073
Definition: nuklear.h:661
struct nk_style_tab tab
Definition: nuklear.h:3795
struct nk_color border_color
Definition: nuklear.h:3419
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect *, struct nk_context *, struct nk_vec2)
NK_API double nk_strtod(const char *str, const char **endptr)
struct nk_window win
Definition: nuklear.h:4104
NK_API void nk_window_close(struct nk_context *ctx, const char *name)
struct nk_clipboard clip
Definition: nuklear.h:2845
nk_style_cursor
Definition: nuklear.h:2167
struct nk_window * begin
Definition: nuklear.h:4162
NK_API void nk_style_default(struct nk_context *)
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
NK_API int nk_input_has_mouse_click_down_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect, int down)
#define NK_FLOAT_STACK_SIZE
Definition: nuklear.h:4034
Definition: nuklear.h:1840
Definition: nuklear.h:3518
Definition: nuklear.h:2957
Definition: nuklear.h:3824
float y
Definition: nuklear.h:3841
Definition: nuklear.h:3825
int active
Definition: nuklear.h:3957
Definition: nuklear.h:665
NK_API void nk_free(struct nk_context *)
struct nk_color text_normal
Definition: nuklear.h:3592
unsigned short point_count
Definition: nuklear.h:3087
Definition: nuklear.h:496
int buffer_size
Definition: versiongenerate.py:65
Definition: nuklear.h:971
NK_API char * nk_str_at_char(struct nk_str *, int pos)
Definition: nuklear.h:699
Definition: nuklear.h:697
NK_API int nk_button_label_styled(struct nk_context *, const struct nk_style_button *, const char *title)
NK_API struct nk_color nk_rgb(int r, int g, int b)
NK_API int nk_tree_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
Definition: nuklear.h:474
enum nk_symbol_type sym_active
Definition: nuklear.h:3676
Definition: nuklear.h:500
NK_API void nk_combobox_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size)
unsigned int has_scrolling
Definition: nuklear.h:3896
int len
Definition: nuklear.h:2730
unsigned int type
Definition: nuklear.h:2658
NK_API void nk_tree_state_pop(struct nk_context *)
NK_API int nk_combo_begin_label(struct nk_context *, const char *selected, struct nk_vec2 size)
NK_API int nk_stricmpn(const char *s1, const char *s2, int n)
Definition: nuklear.h:672
#define NK_UINT32
Definition: nuklear.h:359
unsigned int table_count
Definition: nuklear.h:3988
NK_API int nk_style_push_flags(struct nk_context *, nk_flags *, nk_flags)
int select_start
Definition: nuklear.h:3961
int index
Definition: nuklear.h:3836
struct nk_style_item active
Definition: nuklear.h:3659
NK_API void nk_window_collapse_if(struct nk_context *, const char *name, enum nk_collapse_states, int cond)
Definition: nuklear.h:2008
struct nk_vec2 button_padding
Definition: nuklear.h:3682
Definition: nuklear.h:1862
float contextual_border
Definition: nuklear.h:3753
Definition: nuklear.h:2159
Definition: nuklear.h:1181
char text[NK_INPUT_MAX]
Definition: nuklear.h:3185
NK_API void nk_layout_reset_min_row_height(struct nk_context *)
void(* nk_plugin_copy)(nk_handle, const char *, int len)
Definition: nuklear.h:482
unsigned char active
Definition: nuklear.h:2858
float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS]
Definition: nuklear.h:3870
NK_API void nk_buffer_push(struct nk_buffer *, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align)
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx)
NK_API void nk_color_fv(float *rgba_out, struct nk_color)
int state
Definition: nuklear.h:3966
NK_API int nk_input_is_mouse_prev_hovering_rect(const struct nk_input *, struct nk_rect)
Definition: nuklear.h:2835
Definition: nuklear.h:3577
nk_keys
Definition: nuklear.h:660
unsigned arc_segment_count
Definition: nuklear.h:986
#define NK_INT16
Definition: nuklear.h:343
struct nk_command header
Definition: nuklear.h:3092
Definition: nuklear.h:2949
Definition: nuklear.h:3709
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols)
nk_size end
Definition: nuklear.h:3131
nk_style_item_type
Definition: nuklear.h:3367
const struct nk_cursor * cursor_active
Definition: nuklear.h:3777
Definition: nuklear.h:2676
unsigned circle_segment_count
Definition: nuklear.h:985
enum nk_symbol_type dec_symbol
Definition: nuklear.h:3510
int prev
Definition: nuklear.h:3947
struct nk_command header
Definition: nuklear.h:3020
Definition: nuklear.h:2728
struct nk_command header
Definition: nuklear.h:2970
Definition: nuklear.h:2153
Definition: nuklear.h:2002
Definition: nuklear.h:467
Definition: nuklear.h:3919
struct nk_vec2i b
Definition: nuklear.h:3023
struct nk_style_button button
Definition: nuklear.h:3782
Definition: nuklear.h:1177
struct nk_style_scrollbar scrollh
Definition: nuklear.h:3793
Definition: nuklear.h:1839
NK_API int nk_input_is_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
NK_API void nk_group_scrolled_end(struct nk_context *)
const float * ratio
Definition: nuklear.h:3863
NK_API int nk_contextual_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
unsigned char single_line
Definition: nuklear.h:2857
Definition: nuklear.h:2012
Definition: nuklear.h:1178
struct nk_color foreground
Definition: nuklear.h:3113
struct nk_vec2 padding
Definition: nuklear.h:3765
Definition: nuklear.h:2145
struct nk_table tbl
Definition: nuklear.h:4102
struct nk_panel * parent
Definition: nuklear.h:3902
NK_API void nk_layout_set_min_row_height(struct nk_context *, float height)
struct nk_style_item normal
Definition: nuklear.h:3613
struct nk_vec2 scrollbar
Definition: nuklear.h:2848
NK_API struct nk_vec2 nk_vec2(float x, float y)
unsigned char padding1
Definition: nuklear.h:2859
NK_API void nk_menubar_end(struct nk_context *)
struct nk_vec2 scrollbar_size
Definition: nuklear.h:3606
NK_API void nk_buffer_mark(struct nk_buffer *, enum nk_buffer_allocation_type type)
#define NK_WINDOW_MAX_NAME
Definition: nuklear.h:3909
Definition: nuklear.h:676
nk_uint * offset_x
Definition: nuklear.h:3890
int begin
Definition: nuklear.h:1801
typedef void(ENET_CALLBACK *ENetPacketFreeCallback)(struct _ENetPacket *)
struct nk_config_stack_user_font fonts
Definition: nuklear.h:4083
union nk_page_data data
Definition: nuklear.h:4108
Definition: nuklear.h:2005
NK_API int nk_combo_begin_symbol(struct nk_context *, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_image(struct nk_context *, struct nk_image)
float footer_height
Definition: nuklear.h:3893
Definition: nuklear.h:2156
#define NK_VECTOR_STACK_SIZE
Definition: nuklear.h:4038
Definition: nuklear.h:2961
Definition: nuklear.h:3123
struct nk_draw_null_texture null
Definition: nuklear.h:988
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Definition: nuklear.h:3372
NK_API int nk_strlen(const char *str)
struct nk_style_item normal
Definition: nuklear.h:3579
float height
Definition: nuklear.h:2484
unsigned short rounding
Definition: nuklear.h:3003
Definition: nuklear.h:692
struct nk_page * next
Definition: nuklear.h:4115
NK_API float nk_strtof(const char *str, const char **endptr)
NK_UINT32 nk_uint
Definition: nuklear.h:400
struct nk_vec2 spacing
Definition: nuklear.h:3683
#define NK_SIZE_TYPE
Definition: nuklear.h:374
struct nk_color bar_active
Definition: nuklear.h:3489
Definition: nuklear.h:2942
Definition: nuklear.h:3737
struct nk_color cursor_text_normal
Definition: nuklear.h:3588
NK_API struct nk_color nk_rgb_fv(const float *rgb)
NK_API int nk_window_is_collapsed(struct nk_context *ctx, const char *name)
int tree_depth
Definition: nuklear.h:3869
NK_API void nk_draw_text(struct nk_command_buffer *, struct nk_rect, const char *text, int len, const struct nk_user_font *, struct nk_color, struct nk_color)
float b
Definition: nuklear.h:454
enum nk_allocation_type type
Definition: nuklear.h:4121
struct nk_command header
Definition: nuklear.h:3084
unsigned int seq
Definition: nuklear.h:3970
struct nk_buffer memory
Definition: nuklear.h:4134
nk_text_align
Definition: nuklear.h:1861
NK_API struct nk_color nk_hsva_iv(const int *hsva)
NK_API void nk_combobox(struct nk_context *, const char **items, int count, int *selected, int item_height, struct nk_vec2 size)
struct nk_scroll scrollbar
Definition: nuklear.h:3951
NK_API void nk_buffer_reset(struct nk_buffer *, enum nk_buffer_allocation_type type)
NK_API int nk_str_insert_text_runes(struct nk_str *, int pos, const nk_rune *, int)
enum nk_symbol_type sym_maximize
Definition: nuklear.h:3698
NK_API void nk_textedit_delete_selection(struct nk_text_edit *)
struct nk_window * end
Definition: nuklear.h:4163
Definition: nuklear.h:680
Definition: nuklear.h:2151
struct nk_rect item
Definition: nuklear.h:3868
NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color)
NK_API int nk_group_scrolled_offset_begin(struct nk_context *, nk_uint *x_offset, nk_uint *y_offset, const char *, nk_flags)
float item_offset
Definition: nuklear.h:3866
Definition: nuklear.h:461
struct nk_color text
Definition: nuklear.h:3690
NK_API struct nk_color nk_rgba(int r, int g, int b, int a)
Definition: nuklear.h:2673
NK_API void * nk_buffer_memory(struct nk_buffer *)
nk_text_edit_type
Definition: nuklear.h:2833
NK_API void nk_textedit_init_fixed(struct nk_text_edit *, void *memory, nk_size size)
NK_API int nk_init_fixed(struct nk_context *, void *memory, nk_size size, const struct nk_user_font *)
unsigned short h
Definition: nuklear.h:3005
#define NK_SATURATE(x)
Definition: nuklear.h:4179
struct nk_style_slider slider
Definition: nuklear.h:3788
struct nk_color label_active
Definition: nuklear.h:3621
Definition: nuklear.h:2142
Definition: nuklear.h:3853
NK_API void nk_stroke_curve(struct nk_command_buffer *, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color)
float popup_border
Definition: nuklear.h:3757
NK_API int nk_button_image(struct nk_context *, struct nk_image img)
NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region)
nk_hash name
Definition: nuklear.h:3944
float border
Definition: nuklear.h:3679
NK_API int nk_combo(struct nk_context *, const char **items, int count, int selected, int item_height, struct nk_vec2 size)
Definition: nuklear.h:3969
Definition: nuklear.h:2163
Definition: nuklear.h:1182
nk_byte a
Definition: nuklear.h:453
NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a)
NK_API void nk_str_clear(struct nk_str *)
float rounding
Definition: nuklear.h:3651
float a[2]
Definition: nuklear.h:3064
#define NK_TEXTEDIT_UNDOCHARCOUNT
Definition: nuklear.h:2807
NK_API const void * nk_buffer_memory_const(const struct nk_buffer *)
#define nk_ptr_add_const(t, p, i)
Definition: nuklear.h:4196
Definition: nuklear.h:2956
NK_API void nk_buffer_init_fixed(struct nk_buffer *, void *memory, nk_size size)
float x
Definition: nuklear.h:457
Definition: nuklear.h:977
NK_API void nk_layout_row_template_begin(struct nk_context *, float row_height)
Definition: nuklear.h:2140
NK_API void nk_popup_close(struct nk_context *)
NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color)
Definition: nuklear.h:2152
short x
Definition: nuklear.h:3114
nk_uint nk_rune
Definition: nuklear.h:406
struct nk_page_element * freelist
Definition: nuklear.h:4124
struct nk_window * next
Definition: nuklear.h:3991
NK_API struct nk_color nk_color_picker(struct nk_context *, struct nk_color, enum nk_color_format)
struct nk_vec2 combo_padding
Definition: nuklear.h:3768
NK_API int nk_str_append_text_utf8(struct nk_str *, const char *, int)
struct nk_color text_hover
Definition: nuklear.h:3427
NK_API void nk_text_colored(struct nk_context *, const char *, int, nk_flags, struct nk_color)
int end
Definition: nuklear.h:1801
struct nk_config_stack_flags flags
Definition: nuklear.h:4081
nk_panel_set
Definition: nuklear.h:3823
unsigned short w
Definition: nuklear.h:3115
float x
Definition: nuklear.h:3841
struct nk_image image
Definition: nuklear.h:3373
float cursor_rounding
Definition: nuklear.h:3535
NK_API int nk_checkbox_flags_text(struct nk_context *, const char *, int, unsigned int *flags, unsigned int value)
Definition: nuklear.h:4101
NK_API int nk_button_image_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img)
unsigned short line_thickness
Definition: nuklear.h:2985
int total_height
Definition: nuklear.h:1803
NK_API struct nk_rect nk_rect(float x, float y, float w, float h)
Definition: nuklear.h:3923
nk_orientation
Definition: nuklear.h:468
NK_API void nk_style_show_cursor(struct nk_context *)
struct nk_color text_background
Definition: nuklear.h:3464
struct nk_window * prev
Definition: nuklear.h:3992
int cursor
Definition: nuklear.h:3948
struct nk_vec2 min_size
Definition: nuklear.h:3763
struct nk_command header
Definition: nuklear.h:3052
struct nk_color color
Definition: nuklear.h:3048
float spacing
Definition: nuklear.h:3435
Definition: nuklear.h:2943
nk_widget_layout_states
Definition: nuklear.h:1830
Definition: nuklear.h:2950
struct nk_style_scrollbar scrollv
Definition: nuklear.h:3794
NK_API void nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type, struct nk_color, struct nk_color active, int count, float min_value, float max_value)
NK_API int nk_style_push_font(struct nk_context *, const struct nk_user_font *)
enum nk_anti_aliasing line_AA
Definition: nuklear.h:983
nk_collapse_states
Definition: nuklear.h:469
short redo_point
Definition: nuklear.h:2828
NK_API const char * nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len)
Definition: nuklear.h:499
Definition: nuklear.h:456
NK_API int nk_chart_begin_colored(struct nk_context *, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max)
NK_API void nk_style_hide_cursor(struct nk_context *)
NK_API int nk_menu_begin_image_text(struct nk_context *, const char *, int, nk_flags align, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:3849
struct nk_color border_color
Definition: nuklear.h:3484
Definition: nuklear.h:1833
Definition: nuklear.h:2144
NK_API int nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *, const char *title, nk_flags)
struct nk_color color
Definition: nuklear.h:3006
NK_API void nk_str_remove_runes(struct nk_str *str, int len)
struct nk_vec2 spacing
Definition: nuklear.h:3761
float item_width
Definition: nuklear.h:3864
Definition: nuklear.h:2945
Definition: nuklear.h:2169
Definition: nuklear.h:3479
#define NK_ALIGN_PTR(x, mask)
Definition: nuklear.h:4217
struct nk_color color
Definition: nuklear.h:3025
int cursor_visible
Definition: nuklear.h:3779
NK_API int nk_widget_has_mouse_click_down(struct nk_context *, enum nk_buttons, int down)
#define NK_CLAMP(i, v, x)
Definition: nuklear.h:317
struct nk_style_combo combo
Definition: nuklear.h:3796
struct nk_style_property property
Definition: nuklear.h:3790
unsigned short region[4]
Definition: nuklear.h:461
NK_API void nk_input_begin(struct nk_context *)
int length
Definition: nuklear.h:3959
struct nk_color contextual_border_color
Definition: nuklear.h:3745
Definition: nuklear.h:3028
NK_API int nk_option_text(struct nk_context *, const char *, int, int active)
void * ptr
Definition: nuklear.h:460
struct nk_menu_state menu
Definition: nuklear.h:3898
NK_API void nk_stroke_rect(struct nk_command_buffer *, struct nk_rect, float rounding, float line_thickness, struct nk_color)
NK_API int nk_menu_begin_symbol_text(struct nk_context *, const char *, int, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_push_scissor(struct nk_command_buffer *, struct nk_rect)
NK_API const struct nk_command * nk__begin(struct nk_context *)
float min_height
Definition: nuklear.h:3861
NK_API nk_flags nk_chart_push_slot(struct nk_context *, float, int)
Definition: nuklear.h:2147
nk_edit_flags
Definition: nuklear.h:1996
#define NK_INBOX(px, py, x, y, w, h)
Definition: nuklear.h:4183
int value
Definition: der_length_ia5_string.c:21
#define nk_vec2_sub(a, b)
Definition: nuklear.h:4190
Definition: nuklear.h:470
NK_API int nk_str_append_str_char(struct nk_str *, const char *)
float indent
Definition: nuklear.h:3703
Definition: nuklear.h:700
struct nk_color selected_color
Definition: nuklear.h:3646
unsigned char initialized
Definition: nuklear.h:2855
Definition: nuklear.h:2148
Definition: nuklear.h:1180
NK_API int nk_input_is_key_down(const struct nk_input *, enum nk_keys)
Definition: nuklear.h:501
NK_API int nk_window_is_hovered(struct nk_context *)
short x
Definition: nuklear.h:3093
NK_API double nk_propertyd(struct nk_context *, const char *name, double min, double val, double max, double step, float inc_per_pixel)
#define NK_PI
Definition: nuklear.h:4174
struct nk_cursor * cursor_last
Definition: nuklear.h:3778
nk_size last
Definition: nuklear.h:3131
NK_API int nk_filter_decimal(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:2018
Definition: nuklear.h:469
float height
Definition: nuklear.h:3116
NK_API int nk_filter_binary(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_init(struct nk_context *, struct nk_allocator *, const struct nk_user_font *)
Definition: nuklear.h:2149
NK_API int nk_radio_label(struct nk_context *, const char *, int *active)
NK_API void nk_contextual_close(struct nk_context *)
short y
Definition: nuklear.h:3038
NK_API int nk_input_has_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
void(* nk_command_custom_callback)(void *canvas, short x, short y, unsigned short w, unsigned short h, nk_handle callback_data)
Definition: nuklear.h:3099
NK_API void nk_textedit_init(struct nk_text_edit *, struct nk_allocator *, nk_size size)
const struct nk_cursor * cursors[NK_CURSOR_COUNT]
Definition: nuklear.h:3776
struct nk_vec2 spacing
Definition: nuklear.h:3502
const struct nk_draw_vertex_layout_element * vertex_layout
Definition: nuklear.h:989
struct nk_style_chart chart
Definition: nuklear.h:3792
#define NK_UTF_SIZE
Definition: nuklear.h:255
struct nk_vec2 popup_padding
Definition: nuklear.h:3767
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
short delete_length
Definition: nuklear.h:2820
NK_API void nk_fill_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, struct nk_color)
NK_API const char * nk_str_get_const(const struct nk_str *)
NK_API int nk_textedit_cut(struct nk_text_edit *)
Definition: nuklear.h:972
NK_API void nk_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
Definition: nuklear.h:3686
struct nk_color cursor_text_hover
Definition: nuklear.h:3589
NK_API int nk_button_image_label_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_combo_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size)
NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color)
float rounding
Definition: nuklear.h:3499
NK_API void nk_stroke_polyline(struct nk_command_buffer *, float *points, int point_count, float line_thickness, struct nk_color col)
NK_API void nk_text_wrap_colored(struct nk_context *, const char *, int, struct nk_color)
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect *, const struct nk_context *)
nk_edit_events
Definition: nuklear.h:2017
NK_API struct nk_vec2 nk_rect_pos(struct nk_rect)
Definition: nuklear.h:3848
struct nk_text_undo_state undo
Definition: nuklear.h:2861
NK_API int nk_input_is_mouse_released(const struct nk_input *, enum nk_buttons)
Definition: nuklear.h:2157
NK_API void nk_property_int(struct nk_context *, const char *name, int min, int *val, int max, int step, float inc_per_pixel)
struct nk_style_button button
Definition: nuklear.h:3673
#define NK_SCROLLBAR_HIDING_TIMEOUT
Definition: nuklear.h:263
enum nk_symbol_type sym_right
Definition: nuklear.h:3625
Definition: nuklear.h:3774
NK_API void nk_color_hex_rgba(char *output, struct nk_color)
#define NK_MIN(a, b)
Definition: nuklear.h:315
Definition: nuklear.h:3917
struct nk_vec2 group_padding
Definition: nuklear.h:3766
Definition: nuklear.h:468
nk_handle userdata
Definition: nuklear.h:485
NK_API void nk_style_load_cursor(struct nk_context *, enum nk_style_cursor, const struct nk_cursor *)
unsigned int size
Definition: nuklear.h:4114
Definition: nuklear.h:455
Definition: nuklear.h:457
NK_API int nk_input_is_mouse_pressed(const struct nk_input *, enum nk_buttons)
Definition: nuklear.h:2158
struct nk_style_item cursor_normal
Definition: nuklear.h:3493
#define NK_VALUE_PAGE_CAPACITY
Definition: nuklear.h:4090
Definition: nuklear.h:474
NK_API void nk_push_custom(struct nk_command_buffer *, struct nk_rect, nk_command_custom_callback, nk_handle usr)
Definition: nuklear.h:3076
Definition: nuklear.h:490
NK_API int nk_str_len_char(struct nk_str *)
int active
Definition: nuklear.h:2677
Definition: nuklear.h:2172
unsigned int clicked
Definition: nuklear.h:3181
NK_API int nk_input_any_mouse_click_in_rect(const struct nk_input *, struct nk_rect)
void * ptr
Definition: nuklear.h:2681
Definition: nuklear.h:2143
NK_API const char * nk_style_get_color_by_name(enum nk_style_colors)
void(* nk_query_font_glyph_f)(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
Definition: nuklear.h:2464
Definition: nuklear.h:3852
NK_API void nk_stroke_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color)
Definition: nuklear.h:975
Definition: nuklear.h:2824
Definition: nuklear.h:662
nk_size vertex_alignment
Definition: nuklear.h:991
NK_API void nk_tooltip_end(struct nk_context *)
Definition: nuklear.h:679
Definition: nuklear.h:502
struct nk_color border_color
Definition: nuklear.h:3645
struct nk_style_item cursor_normal
Definition: nuklear.h:3526
unsigned short h
Definition: nuklear.h:3040
Definition: nuklear.h:2020
Definition: nuklear.h:503
short w
Definition: nuklear.h:458
NK_API void nk_spacing(struct nk_context *, int cols)
Definition: nuklear.h:467
Definition: nuklear.h:2656
Definition: nuklear.h:682
float y
Definition: nuklear.h:455
NK_API struct nk_color nk_rgba_hex(const char *rgb)
struct nk_vec2i points[1]
Definition: nuklear.h:3080
struct nk_vec2 padding
Definition: nuklear.h:3704
struct nk_command header
Definition: nuklear.h:3077
struct nk_style_item active
Definition: nuklear.h:3615
GLuint texture
Definition: sdl2backend.cpp:527
NK_API int nk_button_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags text_alignment)
#define NK_STATIC_ASSERT(exp)
Definition: nuklear.h:304
NK_API struct nk_image nk_subimage_ptr(void *, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API void nk_text_wrap(struct nk_context *, const char *, int)
NK_API struct nk_image nk_image_handle(nk_handle)
NK_API struct nk_image nk_image_ptr(void *)
short y
Definition: nuklear.h:3046
NK_API float nk_window_get_width(const struct nk_context *)
NK_API int nk_image_is_subimage(const struct nk_image *img)
nk_size begin
Definition: nuklear.h:3131
struct nk_command header
Definition: nuklear.h:3002
Definition: nuklear.h:973
Definition: nuklear.h:1179
struct nk_context * ctx
Definition: nuklear.h:1804
unsigned char mode
Definition: nuklear.h:2853
struct nk_style_item hover
Definition: nuklear.h:3482
unsigned short h
Definition: nuklear.h:3115
NK_API void nk_draw_image(struct nk_command_buffer *, struct nk_rect, const struct nk_image *, struct nk_color)
struct nk_color text_hover_active
Definition: nuklear.h:3462
NK_API int nk_selectable_label(struct nk_context *, const char *, nk_flags align, int *value)
struct nk_style_button tab_minimize_button
Definition: nuklear.h:3694
struct nk_vec2 padding
Definition: nuklear.h:3607
NK_API struct nk_color nk_hsva(int h, int s, int v, int a)
struct nk_vec2 spacing
Definition: nuklear.h:3705
#define NK_STYLE_ITEM_STACK_SIZE
Definition: nuklear.h:4030
Definition: nuklear.h:669
NK_API int nk_str_insert_text_utf8(struct nk_str *, int pos, const char *, int)
NK_API void nk_tooltip(struct nk_context *, const char *)
Definition: nuklear.h:2682
struct nk_color text_active
Definition: nuklear.h:3428
#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
Definition: nuklear.h:3808
nk_plugin_alloc alloc
Definition: nuklear.h:486
NK_API void nk_combo_close(struct nk_context *)
struct nk_color text_hover
Definition: nuklear.h:3593
NK_API int nk_radio_text(struct nk_context *, const char *, int, int *active)
NK_API void nk_buffer_clear(struct nk_buffer *)
Definition: nuklear.h:3886
nk_uint scroll_value
Definition: nuklear.h:1806
short undo_char_point
Definition: nuklear.h:2829
enum nk_symbol_type sym_hover
Definition: nuklear.h:3675
int id
Definition: nuklear.h:460
Definition: nuklear.h:2481
NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *)
Definition: nuklear.h:465
nk_uint * offset_y
Definition: nuklear.h:3891
struct nk_command header
Definition: nuklear.h:3069
struct nk_color label_hover
Definition: nuklear.h:3620
Definition: nuklear.h:1838
int select_end
Definition: nuklear.h:2852
NK_API const char * nk_str_at_char_const(const struct nk_str *, int pos)
struct nk_configuration_stacks stacks
Definition: nuklear.h:4138
Definition: nuklear.h:2019
Definition: nuklear.h:3019
NK_API nk_handle nk_handle_id(int)
NK_API int nk_combo_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
unsigned short h
Definition: nuklear.h:3012
NK_UINT8 nk_uchar
Definition: nuklear.h:395
int active
Definition: nuklear.h:3947
NK_API struct nk_color nk_rgb_f(float r, float g, float b)
Definition: nuklear.h:2840
enum nk_allocation_type type
Definition: nuklear.h:2687
float r
Definition: nuklear.h:454
nk_window_flags
Definition: nuklear.h:3913
short x
Definition: nuklear.h:3011
nk_chart_type
Definition: nuklear.h:471
float x
Definition: nuklear.h:455
struct nk_color symbol_hover
Definition: nuklear.h:3669
enum nk_chart_type type
Definition: nuklear.h:3830
Definition: nuklear.h:498
struct nk_rect bounds
Definition: nuklear.h:3889
Definition: nuklear.h:2137
Definition: nuklear.h:2667
NK_API int nk_contextual_item_label(struct nk_context *, const char *, nk_flags align)
#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)
Definition: nuklear.h:4049
NK_API int nk_list_view_begin(struct nk_context *, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count)
float rounding
Definition: nuklear.h:3604
nk_size size
Definition: nuklear.h:4126
struct nk_vec2 padding
Definition: nuklear.h:3469
NK_API void nk_stroke_polygon(struct nk_command_buffer *, float *, int point_count, float line_thickness, struct nk_color)
NK_API void nk_popup_end(struct nk_context *)
unsigned int size
Definition: nuklear.h:4095
int build
Definition: nuklear.h:4159
struct nk_page * pages
Definition: nuklear.h:4123
NK_API void nk_input_motion(struct nk_context *, int x, int y)
NK_API int nk_textedit_paste(struct nk_text_edit *, char const *, int len)
Definition: nuklear.h:3444
NK_API int nk_color_pick(struct nk_context *, struct nk_color *, enum nk_color_format)
Definition: nuklear.h:2948
NK_API int nk_utf_len(const char *, int byte_len)
float g
Definition: nuklear.h:454
Definition: nuklear.h:974
NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading)
Definition: nuklear.h:1837
nk_size vertex_size
Definition: nuklear.h:990
unsigned short w
Definition: nuklear.h:3040
Definition: nuklear.h:1841
NK_API struct nk_color nk_hsva_fv(const float *hsva)
Definition: nuklear.h:462
Definition: nuklear.h:696
nk_size cap
Definition: nuklear.h:4127
Definition: nuklear.h:2003
Definition: nuklear.h:1176
enum nk_symbol_type inc_symbol
Definition: nuklear.h:3509
NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color)
Definition: nuklear.h:4113
unsigned short rounding
Definition: nuklear.h:2994
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3476
#define NK_UINT16
Definition: nuklear.h:346
Definition: nuklear.h:475
unsigned short w
Definition: nuklear.h:461
Definition: nuklear.h:3044
unsigned short w
Definition: nuklear.h:3047
#define NK_TEXTEDIT_UNDOSTATECOUNT
Definition: nuklear.h:2803
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3639
NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value)
struct nk_style_scrollbar scrollbar
Definition: nuklear.h:3583
struct nk_color bar_normal
Definition: nuklear.h:3487
nk_flags last_widget_state
Definition: nuklear.h:4136
Definition: nuklear.h:3927
#define nk_foreach(c, ctx)
Definition: nuklear.h:1011
struct nk_color color
Definition: nuklear.h:3831
struct nk_command header
Definition: nuklear.h:3045
int(* nk_plugin_filter)(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:480
struct nk_style_item normal_active
Definition: nuklear.h:3451
Definition: nuklear.h:476
NK_API float nk_window_get_height(const struct nk_context *)
NK_API float nk_widget_height(struct nk_context *)
NK_API int nk_menu_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API int nk_slide_int(struct nk_context *, int min, int val, int max, int step)
Definition: nuklear.h:3857
NK_API int nk_filter_oct(const struct nk_text_edit *, nk_rune unicode)
float filled
Definition: nuklear.h:3867
#define NK_LEN(a)
Definition: nuklear.h:4180
NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size)
Definition: nuklear.h:2947
Definition: nuklear.h:3109
Definition: nuklear.h:693
NK_API int nk_slider_float(struct nk_context *, float min, float *val, float max, float step)
NK_API int nk_window_is_hidden(struct nk_context *, const char *)
NK_API void nk_fill_triangle(struct nk_command_buffer *, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color)
Definition: nuklear.h:1999
short cx
Definition: nuklear.h:3053
#define NK_INTERN
Definition: nuklear.h:286
struct nk_command_buffer buffer
Definition: nuklear.h:3977
NK_API int nk_slider_int(struct nk_context *, int min, int *val, int max, int step)
nk_size allocated
Definition: nuklear.h:2660
nk_hash name
Definition: nuklear.h:3963
Definition: nuklear.h:468
struct nk_vec2i end
Definition: nuklear.h:2979
NK_API int nk_contextual_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, int down)
NK_API int nk_item_is_any_active(struct nk_context *)
NK_API void nk_label_colored_wrap(struct nk_context *, const char *, struct nk_color)
struct nk_style_toggle checkbox
Definition: nuklear.h:3786
NK_API void nk_input_key(struct nk_context *, enum nk_keys, int down)
NK_API struct nk_style_item nk_style_item_color(struct nk_color)
Definition: nuklear.h:2969
#define SEEK_SET
Definition: zconf.h:388
Definition: nuklear.h:677
NK_API void nk_fill_rect(struct nk_command_buffer *, struct nk_rect, float rounding, struct nk_color)
NK_API int nk_button_push_behavior(struct nk_context *, enum nk_button_behavior)
#define nk_ptr_add(t, p, i)
Definition: nuklear.h:4195
NK_API float nk_slide_float(struct nk_context *, float min, float val, float max, float step)
NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color)
Definition: nuklear.h:667
NK_API void nk_fill_polygon(struct nk_command_buffer *, float *, int point_count, struct nk_color)
nk_size size
Definition: nuklear.h:2681
short x
Definition: nuklear.h:2996
NK_API float nk_widget_width(struct nk_context *)
struct nk_color border_color
Definition: nuklear.h:3523
Definition: nuklear.h:1867
Definition: nuklear.h:3655
#define nk_vec2_add(a, b)
Definition: nuklear.h:4191
NK_API int nk_input_is_mouse_hovering_rect(const struct nk_input *, struct nk_rect)
float cursor_border
Definition: nuklear.h:3534
NK_API int nk_chart_begin(struct nk_context *, enum nk_chart_type, int num, float min, float max)
NK_API int nk_style_pop_vec2(struct nk_context *)
Definition: nuklear.h:2173
struct nk_config_stack_style_item style_items
Definition: nuklear.h:4078
NK_API nk_size nk_buffer_total(struct nk_buffer *)
nk_size size
Definition: nuklear.h:2659
Definition: nuklear.h:681
NK_API nk_handle nk_handle_ptr(void *)
unsigned short h
Definition: nuklear.h:3104
struct nk_style_item cursor_active
Definition: nuklear.h:3495
NK_API void nk_window_show(struct nk_context *, const char *name, enum nk_show_states)
struct nk_style style
Definition: nuklear.h:4133
Definition: nuklear.h:1872
NK_API void nk_tree_pop(struct nk_context *)
float range
Definition: nuklear.h:3833
const struct nk_user_font * font
Definition: nuklear.h:3111
Definition: gtest_output_test_.cc:544
NK_API void nk_textedit_undo(struct nk_text_edit *)
NK_API unsigned nk_check_flags_text(struct nk_context *, const char *, int, unsigned int flags, unsigned int value)
unsigned int count
Definition: nuklear.h:4167
struct nk_popup_state popup
Definition: nuklear.h:3983
NK_API float nk_layout_ratio_from_pixel(struct nk_context *, float pixel_width)
Definition: nuklear.h:1870
NK_API nk_flags nk_edit_buffer(struct nk_context *, nk_flags, struct nk_text_edit *, nk_plugin_filter)
float y
Definition: nuklear.h:457
short x
Definition: nuklear.h:456
struct nk_color right
Definition: nuklear.h:3016
Definition: nuklear.h:3820
NK_API int nk_style_pop_style_item(struct nk_context *)
nk_handle userdata
Definition: nuklear.h:2482
Definition: nuklear.h:497
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:60
nk_plugin_filter filter
Definition: nuklear.h:2847
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3540
NK_API int nk_checkbox_flags_label(struct nk_context *, const char *, unsigned int *flags, unsigned int value)
struct nk_color symbol_active
Definition: nuklear.h:3670
nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT]
Definition: nuklear.h:2826
float scrollbar_hiding_timer
Definition: nuklear.h:3979
NK_API int nk_str_append_str_utf8(struct nk_str *, const char *)
nk_text_alignment
Definition: nuklear.h:1869
Definition: nuklear.h:2941
#define NK_API
Definition: nuklear.h:282
struct nk_rect bounds
Definition: nuklear.h:3975
Definition: nuklear.h:2834
unsigned short w
Definition: nuklear.h:3104
NK_API int nk_window_is_active(struct nk_context *, const char *)
Definition: nuklear.h:471
unsigned short line_thickness
Definition: nuklear.h:3039
Definition: nuklear.h:466
struct nk_style_window_header header
Definition: nuklear.h:3738
Definition: nuklear.h:3710
float global_alpha
Definition: nuklear.h:982
struct nk_command header
Definition: nuklear.h:3010
Definition: nuklear.h:3101
struct nk_color color
Definition: nuklear.h:2998
Definition: nuklear.h:470
unsigned capacity
Definition: nuklear.h:4125
NK_API int nk_style_push_color(struct nk_context *, struct nk_color *, struct nk_color)
struct nk_vec2 padding
Definition: nuklear.h:3652
Definition: nuklear.h:2006
NK_API void nk_style_load_all_cursors(struct nk_context *, struct nk_cursor *)
struct nk_vec2 touch_padding
Definition: nuklear.h:3470
struct nk_color color
Definition: nuklear.h:3070
struct nk_style_item fixed_background
Definition: nuklear.h:3739
Definition: nuklear.h:2139
nk_byte b
Definition: nuklear.h:453
NK_API int nk_input_has_mouse_click(const struct nk_input *, enum nk_buttons)
NK_API int nk_combo_begin_color(struct nk_context *, struct nk_color color, struct nk_vec2 size)
NK_API void nk_str_free(struct nk_str *)
int show_buttons
Definition: nuklear.h:3506
NK_API int nk_option_label(struct nk_context *, const char *, int active)
float border
Definition: nuklear.h:3533
nk_allocation_type
Definition: nuklear.h:2665
void(* nk_plugin_free)(nk_handle, void *old)
Definition: nuklear.h:479
struct nk_vec2i a
Definition: nuklear.h:3030
nk_plugin_paste paste
Definition: nuklear.h:2813
NK_API int nk_combo_begin_image_label(struct nk_context *, const char *selected, struct nk_image, struct nk_vec2 size)
nk_size next
Definition: nuklear.h:2963
struct nk_color color
Definition: nuklear.h:3078
struct nk_style_item background
Definition: nuklear.h:3688
Definition: nuklear.h:2154
NK_API void nk_textedit_free(struct nk_text_edit *)
struct nk_scroll scrollbar
Definition: nuklear.h:3976
NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color)
struct nk_buffer * base
Definition: nuklear.h:3127
float(* nk_text_width_f)(nk_handle, float h, const char *, int len)
Definition: nuklear.h:2463
int use_clipping
Definition: nuklear.h:3129
NK_API struct nk_command_buffer * nk_window_get_canvas(struct nk_context *)
NK_API int nk_checkbox_text(struct nk_context *, const char *, int, int *active)
nk_uint nk_hash
Definition: nuklear.h:404
NK_API int nk_str_len(struct nk_str *)
nk_command_type
Definition: nuklear.h:2938
NK_API nk_flags nk_edit_string(struct nk_context *, nk_flags, char *buffer, int *len, int max, nk_plugin_filter)
NK_API void nk_edit_unfocus(struct nk_context *)
unsigned int old
Definition: nuklear.h:3946
nk_size calls
Definition: nuklear.h:2662
Definition: nuklear.h:686
Definition: nuklear.h:1866
struct nk_vec2 pos
Definition: nuklear.h:3170
Definition: nuklear.h:2671
struct nk_style_item hover
Definition: nuklear.h:3614
Definition: nuklear.h:684
NK_API int nk_combo_item_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags alignment)
NK_API int nk_combo_begin_symbol_text(struct nk_context *, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:2165
#define NK_INPUT_MAX
Definition: nuklear.h:257
NK_API int nk_menu_begin_symbol_label(struct nk_context *, const char *, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:2013
NK_API void nk_buffer_free(struct nk_buffer *)
Definition: nuklear.h:2951
NK_API struct nk_color nk_hsv_f(float h, float s, float v)
nk_hash name
Definition: nuklear.h:3971
struct nk_style_item cursor_active
Definition: nuklear.h:3528
struct nk_color color
Definition: nuklear.h:3041
struct nk_style_item normal
Definition: nuklear.h:3481
NK_API int nk_button_symbol(struct nk_context *, enum nk_symbol_type)
NK_API int nk_checkbox_label(struct nk_context *, const char *, int *active)
int use_pool
Definition: nuklear.h:4160
struct nk_vec2 scroll_delta
Definition: nuklear.h:3173
NK_API int nk_window_is_closed(struct nk_context *, const char *)
struct nk_vec2 padding
Definition: nuklear.h:3433
Definition: nuklear.h:469
Definition: nuklear.h:685
NK_API int nk_group_begin(struct nk_context *, const char *title, nk_flags)
Definition: nuklear.h:3091
Definition: nuklear.h:3036
NK_API void nk_buffer_info(struct nk_memory_status *, struct nk_buffer *)
NK_API const char * nk_str_at_const(const struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_color symbol_normal
Definition: nuklear.h:3668
struct nk_vec2 delta
Definition: nuklear.h:3172
Definition: nuklear.h:4077
#define NK_COLOR_STACK_SIZE
Definition: nuklear.h:4046
float row_padding
Definition: nuklear.h:3608
struct nk_style_item normal
Definition: nuklear.h:3416
enum nk_panel_row_layout_type type
Definition: nuklear.h:3858
NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color)
Definition: nuklear.h:981
#define NK_BETWEEN(x, a, b)
Definition: nuklear.h:4182
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx)
NK_API void nk_clear(struct nk_context *)
struct nk_color cursor_border_color
Definition: nuklear.h:3529
Definition: nuklear.h:2141
Definition: nuklear.h:674
float w
Definition: nuklear.h:457
struct nk_color border_color
Definition: nuklear.h:3616
NK_API void nk_menu_end(struct nk_context *)
#define NK_CONTAINER_OF(ptr, type, member)
Definition: nuklear.h:4223
struct nk_style_item hover
Definition: nuklear.h:3447
NK_API int nk_selectable_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int *value)
NK_API nk_flags nk_chart_push(struct nk_context *, float)
NK_API unsigned nk_check_flags_label(struct nk_context *, const char *, unsigned int flags, unsigned int value)
float rounding
Definition: nuklear.h:3468
NK_API int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API float nk_propertyf(struct nk_context *, const char *name, float min, float val, float max, float step, float inc_per_pixel)
NK_API int nk_input_is_key_released(const struct nk_input *, enum nk_keys)
Definition: nuklear.h:495
struct nk_color cursor_hover
Definition: nuklear.h:3587
struct nk_style_item hover
Definition: nuklear.h:3521
Definition: nuklear.h:2983
Definition: nuklear.h:3068
enum nk_command_type type
Definition: nuklear.h:2962
float rounding
Definition: nuklear.h:3680
struct nk_color text_active
Definition: nuklear.h:3594
NK_API struct nk_rect nk_widget_bounds(struct nk_context *)
struct nk_config_stack_vec2 vectors
Definition: nuklear.h:4080
float border
Definition: nuklear.h:3701
Definition: nuklear.h:473
Definition: nuklear.h:2944
short y
Definition: nuklear.h:2971
NK_API void nk_window_show_if(struct nk_context *, const char *name, enum nk_show_states, int cond)
NK_API int nk_tree_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
nk_color_format
Definition: nuklear.h:473
struct nk_command header
Definition: nuklear.h:3110
float combo_border
Definition: nuklear.h:3752
struct nk_color cursor_normal
Definition: nuklear.h:3586
struct nk_command header
Definition: nuklear.h:3102
nk_hash keys[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:4096
NK_API struct nk_color nk_hsv_iv(const int *hsv)
NK_API int nk_menu_begin_image(struct nk_context *, const char *, struct nk_image, struct nk_vec2 size)
struct nk_color popup_border_color
Definition: nuklear.h:3743
NK_API int nk_menu_begin_image_label(struct nk_context *, const char *, nk_flags align, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:4107
NK_API int nk_str_insert_at_char(struct nk_str *, int pos, const char *, int)
Definition: nuklear.h:1832
Definition: nuklear.h:2811
NK_API int nk_selectable_text(struct nk_context *, const char *, int, nk_flags align, int *value)
NK_UINT16 nk_ushort
Definition: nuklear.h:398
Definition: nuklear.h:3083
Definition: nuklear.h:1863
Definition: nuklear.h:3921
unsigned int old
Definition: nuklear.h:3965
nk_size size
Definition: nuklear.h:2699
enum nk_panel_type type
Definition: nuklear.h:3887
NK_API int nk_input_is_mouse_down(const struct nk_input *, enum nk_buttons)
NK_API nk_size nk_prog(struct nk_context *, nk_size cur, nk_size max, int modifyable)
NK_API int nk_filter_float(const struct nk_text_edit *, nk_rune unicode)
struct nk_vec2i begin
Definition: nuklear.h:2986
Definition: nuklear.h:3915
nk_handle callback_data
Definition: nuklear.h:3105
NK_API void nk_input_end(struct nk_context *)
NK_API int nk_button_pop_behavior(struct nk_context *)
float h
Definition: nuklear.h:457
struct nk_color selected_normal
Definition: nuklear.h:3597
NK_API void nk_layout_row(struct nk_context *, enum nk_layout_format, float height, int cols, const float *ratio)
NK_API void nk_layout_row_template_end(struct nk_context *)
Definition: nuklear.h:2162
Definition: nuklear.h:1842
float rounding
Definition: nuklear.h:3760
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3515
NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a)
struct nk_style_edit edit
Definition: nuklear.h:3632
NK_API int nk_combo_string(struct nk_context *, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size)
struct nk_style_toggle option
Definition: nuklear.h:3785
struct nk_panel pan
Definition: nuklear.h:4103
Definition: nuklear.h:678
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score)
struct nk_buffer_marker marker[NK_BUFFER_MAX]
Definition: nuklear.h:2683
NK_API int nk_combo_begin_image_text(struct nk_context *, const char *selected, int, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:2954
Definition: nuklear.h:2155
char string[1]
Definition: nuklear.h:3118
Definition: nuklear.h:2168
int heuristic(Location a, Location b)
Definition: findpath.cpp:59
nk_plugin_copy copy
Definition: nuklear.h:2814
Definition: nuklear.h:3382
struct nk_vec2 size offset
Definition: nuklear.h:462
struct nk_style_item normal
Definition: nuklear.h:3520
NK_API int nk_selectable_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int *value)
Definition: nuklear.h:666
struct nk_style_button node_minimize_button
Definition: nuklear.h:3696
Definition: nuklear.h:3855
unsigned short line_thickness
Definition: nuklear.h:3055
NK_API int nk_check_text(struct nk_context *, const char *, int, int active)
short y
Definition: nuklear.h:3114
struct nk_text_edit text_edit
Definition: nuklear.h:4154
NK_API int nk_style_push_style_item(struct nk_context *, struct nk_style_item *, struct nk_style_item)
Definition: nuklear.h:2170
NK_API void nk_textedit_delete(struct nk_text_edit *, int where, int len)
int slot
Definition: nuklear.h:3840
NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed)
struct nk_style_item active
Definition: nuklear.h:3418
char name_string[NK_WINDOW_MAX_NAME]
Definition: nuklear.h:3972
Definition: nuklear.h:4130
typedef int(ENET_CALLBACK *ENetInterceptCallback)(struct _ENetHost *host
Definition: nuklear.h:2975
struct nk_page_element * prev
Definition: nuklear.h:4110
short x
Definition: nuklear.h:458
enum nk_anti_aliasing shape_AA
Definition: nuklear.h:984
Definition: nuklear.h:1831
struct nk_rect clip
Definition: nuklear.h:3128
struct nk_panel * layout
Definition: nuklear.h:3978
int length
Definition: nuklear.h:3117
NK_API void nk_style_set_font(struct nk_context *, const struct nk_user_font *)
struct nk_color left
Definition: nuklear.h:3013
Definition: nuklear.h:2992
struct nk_str string
Definition: nuklear.h:2846
nk_handle userdata
Definition: nuklear.h:3637
Definition: nuklear.h:466
Definition: nuklear.h:2004
#define const
Definition: zconf.h:196
short char_storage
Definition: nuklear.h:2821
short redo_char_point
Definition: nuklear.h:2830
int sel_start
Definition: nuklear.h:3949
struct nk_command header
Definition: nuklear.h:2984
short x
Definition: nuklear.h:3103
struct nk_clipboard clip
Definition: nuklear.h:4135
NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color)
struct nk_vec2 content_padding
Definition: nuklear.h:3681
unsigned short line_thickness
Definition: nuklear.h:2995
enum nk_style_item_type type
Definition: nuklear.h:3378
NK_API void nk_label_colored(struct nk_context *, const char *, nk_flags align, struct nk_color)
Definition: nuklear.h:3956
Definition: nuklear.h:471
struct nk_color text_normal
Definition: nuklear.h:3426
Definition: nuklear.h:690
struct nk_color label_hover
Definition: nuklear.h:3664
Definition: nuklear.h:2164
NK_API int nk_check_label(struct nk_context *, const char *, int active)
struct nk_command header
Definition: nuklear.h:3061
NK_API void nk_window_set_bounds(struct nk_context *, struct nk_rect bounds)
nk_layout_format
Definition: nuklear.h:475
struct nk_color bar_filled
Definition: nuklear.h:3490
Definition: nuklear.h:2171
Definition: nuklear.h:3414
Definition: nuklear.h:452
Definition: nuklear.h:3122
short y
Definition: nuklear.h:456
NK_API void nk_end(struct nk_context *ctx)
NK_API int nk_menu_begin_symbol(struct nk_context *, const char *, enum nk_symbol_type, struct nk_vec2 size)
NK_API int nk_strfilter(const char *text, const char *regexp)
NK_API void nk_combobox_string(struct nk_context *, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size)
nk_text_width_f width
Definition: nuklear.h:2486
char buffer[NK_MAX_NUMBER_BUFFER]
Definition: nuklear.h:3958
Definition: nuklear.h:494
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3440
NK_API char * nk_str_get(struct nk_str *)
NK_UINT8 nk_byte
Definition: nuklear.h:396
#define NK_CHART_MAX_SLOT
Definition: nuklear.h:3811
struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT]
Definition: nuklear.h:2825
unsigned short h
Definition: nuklear.h:2997
Definition: nuklear.h:2681
Definition: nuklear.h:460
Definition: nuklear.h:493
NK_API int nk_str_append_str_runes(struct nk_str *, const nk_rune *)
NK_API struct nk_color nk_rgba_fv(const float *rgba)
struct nk_config_stack_float floats
Definition: nuklear.h:4079
struct nk_style_button tab_maximize_button
Definition: nuklear.h:3693
#define NK_UNUSED(x)
Definition: nuklear.h:4178
int down
Definition: nuklear.h:3180
Definition: nuklear.h:3377
NK_INT16 nk_short
Definition: nuklear.h:397
short x
Definition: nuklear.h:3004
NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context *)
Definition: nuklear.h:1997
NK_API struct nk_vec2 nk_window_get_content_region_max(struct nk_context *)
NK_API struct nk_rect nk_window_get_content_region(struct nk_context *)
NK_API int nk_select_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int value)
float grow_factor
Definition: nuklear.h:2691
struct nk_vec2 uv
Definition: nuklear.h:979
nk_uint * scroll_pointer
Definition: nuklear.h:1805
Definition: nuklear.h:452
Definition: nuklear.h:471
NK_API void nk_layout_space_begin(struct nk_context *, enum nk_layout_format, float height, int widget_count)
unsigned int seq
Definition: nuklear.h:4168
Definition: nuklear.h:454
int select_end
Definition: nuklear.h:3962
nk_text_edit_mode
Definition: nuklear.h:2838
struct nk_config_stack_color colors
Definition: nuklear.h:4082
struct nk_edit_state edit
Definition: nuklear.h:3984
struct nk_color label_active
Definition: nuklear.h:3665
NK_API void nk_style_from_table(struct nk_context *, const struct nk_color *)
int sel_end
Definition: nuklear.h:3950
#define NK_UINT8
Definition: nuklear.h:340
struct nk_input input
Definition: nuklear.h:4132
NK_API int nk_button_label(struct nk_context *, const char *title)
#define NK_MAX(a, b)
Definition: nuklear.h:316
const struct nk_user_font * font
Definition: nuklear.h:3775
enum nk_button_behavior button_behavior
Definition: nuklear.h:4137
NK_API int nk_button_text(struct nk_context *, const char *title, int len)
NK_API void nk_menubar_begin(struct nk_context *)
NK_API int nk_style_push_float(struct nk_context *, float *, float)
#define NK_PTR_TO_UINT(x)
Definition: nuklear.h:4208
#define NK_FONT_STACK_SIZE
Definition: nuklear.h:4026
NK_API int nk_combo_item_label(struct nk_context *, const char *, nk_flags alignment)
NK_API int nk_button_image_label(struct nk_context *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_button_image_text(struct nk_context *, struct nk_image img, const char *, int, nk_flags alignment)
Definition: nuklear.h:673
Definition: nuklear.h:2817
NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color)
NK_API int nk_str_insert_str_char(struct nk_str *, int pos, const char *)
struct nk_vec2i points[1]
Definition: nuklear.h:3088
Definition: nuklear.h:2138
struct nk_vec2 padding
Definition: nuklear.h:3501
NK_API int nk_menu_begin_label(struct nk_context *, const char *, nk_flags align, struct nk_vec2 size)
unsigned char grabbed
Definition: nuklear.h:3175
NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color)
unsigned char mode
Definition: nuklear.h:3952
NK_API int nk_style_pop_flags(struct nk_context *)
NK_API int nk_button_symbol_text_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API struct nk_color nk_rgb_hex(const char *rgb)
struct nk_style_item hover
Definition: nuklear.h:3658
nk_symbol_type
Definition: nuklear.h:489
NK_API struct nk_color nk_rgb_bv(const nk_byte *rgb)
NK_API int nk_str_insert_str_utf8(struct nk_str *, int pos, const char *)
struct nk_allocator pool
Definition: nuklear.h:2685
NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region)
struct nk_color text_background
Definition: nuklear.h:3429
short cy
Definition: nuklear.h:3062
Definition: nuklear.h:687
NK_API void nk_plot_function(struct nk_context *, enum nk_chart_type, void *userdata, float(*value_getter)(void *user, int index), int count, int offset)
NK_API nk_rune nk_str_rune_at(const struct nk_str *, int pos)
NK_API int nk_style_pop_font(struct nk_context *)
struct nk_style_item hover
Definition: nuklear.h:3417
nk_command_clipping
Definition: nuklear.h:3121
tuple output
Definition: gtest_output_test.py:321
Definition: nuklear.h:3183
int columns
Definition: nuklear.h:3862
unsigned short r
Definition: nuklear.h:3054
int text_len
Definition: nuklear.h:3186
NK_INT32 nk_int
Definition: nuklear.h:399
NK_API int nk_tree_state_push(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states *state)
float border
Definition: nuklear.h:3603
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
Definition: nuklear.h:698
NK_API void nk_textedit_redo(struct nk_text_edit *)
NK_API void nk_menu_close(struct nk_context *)
Definition: nuklear.h:472
NK_API struct nk_vec2 nk_rect_size(struct nk_rect)
Definition: nuklear.h:671
struct nk_style_item background
Definition: nuklear.h:3644
NK_API void nk_str_init(struct nk_str *, const struct nk_allocator *, nk_size size)
NK_API struct nk_image nk_image_id(int)
short y
Definition: nuklear.h:3004
struct nk_color color
Definition: nuklear.h:3057
Definition: nuklear.h:3851
NK_API int nk_combo_begin_image(struct nk_context *, struct nk_image img, struct nk_vec2 size)
Definition: nuklear.h:2940
#define nk_vec2_len_sqr(a)
Definition: nuklear.h:4192
struct nk_style_button inc_button
Definition: nuklear.h:3633
struct nk_command header
Definition: nuklear.h:3037
Definition: nuklear.h:2175
Definition: nuklear.h:3369
NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color)
NK_API void nk_combo_end(struct nk_context *)
Definition: nuklear.h:2953
NK_API int nk_propertyi(struct nk_context *, const char *name, int min, int val, int max, int step, float inc_per_pixel)
Definition: nuklear.h:3818
nk_size calls
Definition: nuklear.h:2697
NK_API void nk_input_char(struct nk_context *, char)
Definition: nuklear.h:3001
NK_API void nk_color_dv(double *rgba_out, struct nk_color)
struct nk_page_element win[1]
Definition: nuklear.h:4116
#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1)
Definition: nuklear.h:4185
NK_API struct nk_vec2 nk_vec2v(const float *xy)
NK_API int nk_tooltip_begin(struct nk_context *, float width)
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3441
NK_API struct nk_rect nk_recti(int x, int y, int w, int h)
NK_API struct nk_panel * nk_window_get_panel(struct nk_context *)
struct nk_vec2 menu_padding
Definition: nuklear.h:3770
struct nk_color label_normal
Definition: nuklear.h:3619
nk_size offset
Definition: nuklear.h:2678
nk_show_states
Definition: nuklear.h:470
struct nk_color color
Definition: nuklear.h:3383
struct nk_style_item pressed
Definition: nuklear.h:3448
NK_API int nk_style_pop_color(struct nk_context *)
NK_API struct nk_color nk_rgba_iv(const int *rgba)
unsigned char single_line
Definition: nuklear.h:3953
struct nk_color selected_hover
Definition: nuklear.h:3598
NK_API void nk_chart_end(struct nk_context *)
short x
Definition: nuklear.h:3046
struct nk_command_buffer * buffer
Definition: nuklear.h:3901
float a
Definition: nuklear.h:454
struct nk_color menu_border_color
Definition: nuklear.h:3746
NK_API int nk_menu_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
Definition: nuklear.h:465
Definition: nuklear.h:1865
Definition: nuklear.h:3847
NK_API int nk_combo_begin_symbol_label(struct nk_context *, const char *selected, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:472
#define NK_ALIGN_PTR_BACK(x, mask)
Definition: nuklear.h:4219
NK_API int nk_style_push_vec2(struct nk_context *, struct nk_vec2 *, struct nk_vec2)
nk_heading
Definition: nuklear.h:465
#define nk_vec2_muls(a, t)
Definition: nuklear.h:4193
nk_style_colors
Definition: nuklear.h:2136
NK_API struct nk_vec2 nk_window_get_content_region_min(struct nk_context *)
NK_API int nk_menu_begin_text(struct nk_context *, const char *title, int title_len, nk_flags align, struct nk_vec2 size)
struct nk_color background
Definition: nuklear.h:3112
struct nk_vec2i end
Definition: nuklear.h:2987
nk_handle userdata
Definition: nuklear.h:3130
Definition: nuklear.h:491
NK_API struct nk_rect nk_rectiv(const int *xywh)
unsigned short h
Definition: nuklear.h:461
struct nk_color border_color
Definition: nuklear.h:3689
NK_API struct nk_vec2 nk_widget_size(struct nk_context *)
NK_API void nk_layout_row_push(struct nk_context *, float value)
nk_flags text_alignment
Definition: nuklear.h:3430